JPA equivalent command for Hibernate.initialize

I have a Lazy collection that I want to initialize as I see fit in my service / controller. At this moment I can do:

Hibernate.initialize( myEntity.getListOfThings() );

This command is hibernated and does not make the JPA implementation transparent. Is there an elegant way to JPA?

+1
source share
1 answer

No, there is no JPA equivalent. You can find out if the object is loaded , and use one of the two parameters, or access to the properties while the object is still tied to the persistence context, which I usually see the calling size, only to initialize the collection

myEntity.getListOfThings().size();

or use the query to initialize.

+1
source

Source: https://habr.com/ru/post/1685818/


All Articles