Search in sources :

Example 1 with PersistentAttributeInterceptor

use of org.hibernate.engine.spi.PersistentAttributeInterceptor in project hibernate-orm by hibernate.

the class PojoEntityInstantiator method applyInterception.

@Override
protected Object applyInterception(Object entity) {
    if (!applyBytecodeInterception) {
        return entity;
    }
    PersistentAttributeInterceptor interceptor = new LazyAttributeLoadingInterceptor(entityMetamodel.getName(), entityMetamodel.getBytecodeEnhancementMetadata().getLazyAttributesMetadata().getLazyAttributeNames(), null);
    ((PersistentAttributeInterceptable) entity).$$_hibernate_setInterceptor(interceptor);
    return entity;
}
Also used : LazyAttributeLoadingInterceptor(org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor) PersistentAttributeInterceptor(org.hibernate.engine.spi.PersistentAttributeInterceptor) PersistentAttributeInterceptable(org.hibernate.engine.spi.PersistentAttributeInterceptable)

Example 2 with PersistentAttributeInterceptor

use of org.hibernate.engine.spi.PersistentAttributeInterceptor in project hibernate-orm by hibernate.

the class StatefulPersistenceContext method clear.

@Override
public void clear() {
    for (Object o : proxiesByKey.values()) {
        if (o == null) {
            //entry may be GCd
            continue;
        }
        ((HibernateProxy) o).getHibernateLazyInitializer().unsetSession();
    }
    for (Entry<Object, EntityEntry> objectEntityEntryEntry : entityEntryContext.reentrantSafeEntityEntries()) {
        // todo : I dont think this need be reentrant safe
        if (objectEntityEntryEntry.getKey() instanceof PersistentAttributeInterceptable) {
            final PersistentAttributeInterceptor interceptor = ((PersistentAttributeInterceptable) objectEntityEntryEntry.getKey()).$$_hibernate_getInterceptor();
            if (interceptor instanceof LazyAttributeLoadingInterceptor) {
                ((LazyAttributeLoadingInterceptor) interceptor).unsetSession();
            }
        }
    }
    for (Map.Entry<PersistentCollection, CollectionEntry> aCollectionEntryArray : IdentityMap.concurrentEntries(collectionEntries)) {
        aCollectionEntryArray.getKey().unsetSession(getSession());
    }
    arrayHolders.clear();
    entitiesByKey.clear();
    entitiesByUniqueKey.clear();
    entityEntryContext.clear();
    //		entityEntries.clear();
    parentsByChild.clear();
    entitySnapshotsByKey.clear();
    collectionsByKey.clear();
    collectionEntries.clear();
    if (unownedCollections != null) {
        unownedCollections.clear();
    }
    proxiesByKey.clear();
    nullifiableEntityKeys.clear();
    if (batchFetchQueue != null) {
        batchFetchQueue.clear();
    }
    // defaultReadOnly is unaffected by clear()
    hasNonReadOnlyEntities = false;
    if (loadContexts != null) {
        loadContexts.cleanup();
    }
    naturalIdXrefDelegate.clear();
}
Also used : PersistentCollection(org.hibernate.collection.spi.PersistentCollection) EntityEntry(org.hibernate.engine.spi.EntityEntry) LazyAttributeLoadingInterceptor(org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor) CollectionEntry(org.hibernate.engine.spi.CollectionEntry) PersistentAttributeInterceptor(org.hibernate.engine.spi.PersistentAttributeInterceptor) PersistentAttributeInterceptable(org.hibernate.engine.spi.PersistentAttributeInterceptable) ConcurrentReferenceHashMap(org.hibernate.internal.util.collections.ConcurrentReferenceHashMap) Map(java.util.Map) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) IdentityMap(org.hibernate.internal.util.collections.IdentityMap)

Aggregations

LazyAttributeLoadingInterceptor (org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor)2 PersistentAttributeInterceptable (org.hibernate.engine.spi.PersistentAttributeInterceptable)2 PersistentAttributeInterceptor (org.hibernate.engine.spi.PersistentAttributeInterceptor)2 HashMap (java.util.HashMap)1 IdentityHashMap (java.util.IdentityHashMap)1 Map (java.util.Map)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 PersistentCollection (org.hibernate.collection.spi.PersistentCollection)1 CollectionEntry (org.hibernate.engine.spi.CollectionEntry)1 EntityEntry (org.hibernate.engine.spi.EntityEntry)1 ConcurrentReferenceHashMap (org.hibernate.internal.util.collections.ConcurrentReferenceHashMap)1 IdentityMap (org.hibernate.internal.util.collections.IdentityMap)1