public class LazyLoadingUtil extends Object
Provides a lazy way to resolve all Hibernate proxies.
| Modifier and Type | Method and Description |
|---|---|
protected static Object |
callCollectionGetter(Object entity,
String propertyName)
Calls the getter of a collection property in order to resolve the javassist lazy proxy
object.
|
static <E> Collection<E> |
deepHydrate(org.hibernate.Session currentSession,
Collection<E> entities)
Populate a lazy-initialized object graph by recursivity.
|
static <E> E |
deepHydrate(org.hibernate.Session currentSession,
E entity)
Populate a lazy-initialized object graph by recursivity.
|
protected static String |
getterFromCollection(String propertyName)
Generate the getter name of a collection property.
|
public static <E> Collection<E> deepHydrate(org.hibernate.Session currentSession, 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.
currentSession - Hibernate session still openentities - a Collection of Hibernate entities to loadCollection of Hibernate entities fully loaded. Similar to the entities
input parameter. Useful when calling this method in a return statement.public static <E> E deepHydrate(org.hibernate.Session currentSession,
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.
currentSession - Hibernate session still openentity - a single Hibernate entity or a simple java class referencing entitiesprotected static Object callCollectionGetter(Object entity, String propertyName)
entity - target objectpropertyName - name of the collection property (ie. clients)Copyright © 2012-2015. All Rights Reserved.