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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With