• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get or Load all objects of a type  RSS feed

 
Henry Wong
author
Sheriff
Posts: 23028
120
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Probably a beginner's Hibernate question... but I can't seem to figure this out. I'm new to Hibernate, so be gentle...

To get an object from persistence store, I need to use the get() method (on the Session object). One of the params is the type, and the another param is the id.... but what if I want all the objects of that type? Is there a method where I get a collection (or an iterator)? And where I don't need to specify an id?

Henry
 
Lalit Bhatt
Ranch Hand
Posts: 69
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try HQL. Similar to SQL there is HQL in hibernate which will help you out in fetching the list of objects. Also you might want to look at criteria query.

See Hibernate Tutorials here
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!