Hibernate, check if the collection is fully loaded

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

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

+7
java collections hibernate lazy-loading
source share
1 answer

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

(There is another method - Hibernate.isInitialized(collection) , but since you want to actually load the collection, initialize(..) is the path that performs the same check before proceeding with initialization)

+16
source share

All Articles