Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Create a Sub Query in a Criteria Query

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

Iam facing a problem in creating a sub query within a Criteria Query.Please help:

Sql Query

Select salary from employee_table where

name = Parameter.[name]
age = Parameter.[age]
dateofbirth = Select Max(dateofbirth) from employee_table
where name = Parameter.[name],
age = Parameter.[age],
dateofbirth < = Parameter.[dateofbirth]

Please help as iam stuck on dis code
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can do that by using the 'DetachedCriteria' in hibernate

for e.g.-



since you are passing 'data' as a parameter, so what you do
1)create an object of detachedcriteria first,
2)add the expression,
3) and finally set the projection(in the 2nd line above code) using the 'max()'

refer the link below:-
Hibernate Criteria Queries

enjoy buddy .... :-)
 
Vinod Vinu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do Your Homework
 
reply
    Bookmark Topic Watch Topic
  • New Topic