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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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)