public class JpaLazyLoadingUtil extends Object
Provides a lazy way to resolve all Hibernate proxies.
| Modifier and Type | Method and Description |
|---|---|
static <E> Collection<E> |
deepHydrate(javax.persistence.EntityManager currentEntityManager,
Collection<E> entities)
Populate a lazy-initialized object graph by recursivity.
|
static <E> E |
deepHydrate(javax.persistence.EntityManager currentEntityManager,
E entity)
Populate a lazy-initialized object graph by recursivity.
|
public static <E> Collection<E> deepHydrate(javax.persistence.EntityManager currentEntityManager, Collection<E> entities)
This method deeply navigates into a graph of entities in order to resolve uninitialized
Hibernate proxies.
The goal is to avoid any lazyinitializationexception once entities are detached from
the Hibernate session.
May attention: this method has to be called from an open persistent context / Hibernate
session.
currentEntityManager - current JPA entity manager still openentities - a Collection of Hibernate entities to loadCollection of Hibernate entities fully loaded. Similar to the entities
input parameter. Usefull when calling this method in a return statement.public static <E> E deepHydrate(javax.persistence.EntityManager currentEntityManager,
E entity)
This method deeply navigates into a graph of entities in order to resolve uninitialized
Hibernate proxies.
The goal is to avoid any lazyinitializationexception once entities are detached from
the Hibernate session.
May attention: this method has to be called from an open persistent context / Hibernate
session.
currentEntityManager - current JPA entity manager still openentity - a single Hibernate entity or a simple java class referencing entitiesCopyright © 2012-2015. All Rights Reserved.