• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get or Load all objects of a type

 
Henry Wong
author
Marshal
Pie
Posts: 22124
88
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic