This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help framing Hibernate Criteria based on SQL statement with mutiple clauses.

Rajkamal Pillai
Ranch Hand
Posts: 445
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am trying to frame a Hibernate Criteria nased query for a SQL I am using in an application. The requirement is to find the name of all members who are not married or married with at least 2 children between the ages of {MIN_AGE} and {MAX_AGE}. The table structure and the SQL I use is below.

I tried creating a Criteria object on the POJO and adding Restrictions. Using Criteria/Restrictions objects I get a single query with the clauses minus the brackets? The results vary as the brackets and hence the hierarchy of the query evaluation is altered. Is there any way I get the desired query translated to Hibernate Criteria/Restrictions?

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic