Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate, test if a collection is fully loaded

Is there a way to test if a collection is already initialized? try-catch only?

I have a function work with a lazy collection, and I need to load it only if is not already loaded.

like image 750
blow Avatar asked Oct 02 '10 17:10

blow


1 Answers

Use Hibernate.initialize(collection) This will initialize the collection if it is not yet.

(There is another method - Hibernate.isInitialized(collection), but since you want to actually load the collection, initialize(..) is the way to go - it makes the same check before proceeding to initialization)

like image 176
Bozho Avatar answered Nov 04 '22 21:11

Bozho