Forums Register Login

Get or Load all objects of a type

+Pie Number of slices to send: Send

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
+Pie Number of slices to send: Send
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
Do Re Mi Fa So La Tiny Ad
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 713 times.
Similar Threads
2nd Level cache eviction not cascading
Hibernate 2 deleting by cascade
Hibernate: How can I join these tables?
Lazy loading not working as expected
How to lazily load references when the object is detached from session ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 08:10:14.