This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes Hibernate Criteria Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Criteria" Watch "Hibernate Criteria" New topic
Author

Hibernate Criteria

Pradeep Chandrasekharan Nair
Ranch Hand

Joined: Apr 01, 2004
Posts: 48
I have a Candidate bean and inside that I have Job object. If I criteria on Candidate it will give a list of candidates. Is there any way to get a list of jobs instead of candidates if I create criteria on Candidate?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Well, not really. Basically the class thatyou pass to the creation of the main Criteria object is the list of object types that you are going to get back. So if you want a list of the other objects make your Criteria object based on that. You can always do joins in a Criteria. Check out http://www.javalobby.org/articles/hibernatequery102/ at the bottom, the last two pieces of code you see is creating a join.

Good Luck

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
jQuery in Action, 2nd edition
 
subject: Hibernate Criteria