Search in sources :

Example 1 with StatefulPersistenceContext

use of org.hibernate.engine.internal.StatefulPersistenceContext in project hibernate-orm by hibernate.

the class DefaultLoadEventListener method makeEntityCircularReferenceSafe.

private void makeEntityCircularReferenceSafe(ReferenceCacheEntryImpl referenceCacheEntry, EventSource session, Object entity, EntityKey entityKey) {
    // make it circular-reference safe
    final StatefulPersistenceContext statefulPersistenceContext = (StatefulPersistenceContext) session.getPersistenceContext();
    if ((entity instanceof ManagedEntity)) {
        statefulPersistenceContext.addReferenceEntry(entity, Status.READ_ONLY);
    } else {
        TwoPhaseLoad.addUninitializedCachedEntity(entityKey, entity, referenceCacheEntry.getSubclassPersister(), LockMode.NONE, referenceCacheEntry.getVersion(), session);
    }
    statefulPersistenceContext.initializeNonLazyCollections();
}
Also used : ManagedEntity(org.hibernate.engine.spi.ManagedEntity) StatefulPersistenceContext(org.hibernate.engine.internal.StatefulPersistenceContext)

Aggregations

StatefulPersistenceContext (org.hibernate.engine.internal.StatefulPersistenceContext)1 ManagedEntity (org.hibernate.engine.spi.ManagedEntity)1