Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6564667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:59:44+00:00 2026-05-25T13:59:44+00:00

I would like to translate a query like this one: FROM Entity_1 obj WHERE

  • 0

I would like to translate a query like this one:

FROM Entity_1 obj
WHERE obj IN (FROM Entity2) OR 
      obj IN (FROM Entity3)

To hibernate Criteria form, and the official documentation of Hibernate is not enough because it doesn’t say how to apply the IN statement.

Any hint?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:59:45+00:00Added an answer on May 25, 2026 at 1:59 pm

    The criteria API does not have a provision to add another query as a restriction.. i think what @Niroshan Abayakoon was trying to say is that you need to execute the queries for the IN clause seperatly & add the result to the Restrictions.in() condition.

    List<?> entity2Data=//get data from either a query or criteria
    List<?> entity3Data=//get data from either a query or criteria
    Criteria c = // obtain criteria from session
    // basically creates an OR condition chain
    Disjunction orConditions = Restrctions.disjunction();
    orConditions.add(Restrictions.in("obj", entity2Data));
    orConditions.add(Restrictions.in("obj", entity3Data));
    c.add(orConditions); 
    

    this would get hibernate to consider the list within the IN clause.

    Its always better to fallback to HQL in situations like this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to translate this MySQL query to the Zend format: SELECT count_panne,
How to translate query like select 1, 2 (i.e. without FROM clause) to LINQ
I would like to translate or 301-redirect urls such as: www.domain.com/example.html to www.domain.com/example Here
I've got some code which I would like to translate into Opengl ES. I'm
I would like to translate the following Unix 1 Liner to PowerShell. Synopsis of
I have 2 tables that I need to get information from, and would like
I have a biology database that I would like to query. There is also
I would like to build a web interface to present logdata. This should be
I would like to implement a generic Linq query on a DataGridView.DataSource to retreive
Would like to get a list of advantages and disadvantages of using Stored Procedures.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.