public void afterReassociate(Object entity, SharedSessionContractImplementor session) { if ( getEntityMetamodel().getBytecodeEnhancementMetadata().isEnhancedForLazyLoading() ) { LazyAttributeLoadingInterceptor interceptor = getEntityMetamodel().getBytecodeEnhancementMetadata().extractInterceptor( entity ); if ( interceptor == null ) { getEntityMetamodel().getBytecodeEnhancementMetadata().injectInterceptor( entity, session ); } else { interceptor.setSession( session ); } } handleNaturalIdReattachment( entity, session ); }
private void checkInterceptor(Parent parent, boolean isNullExpected) { final BytecodeEnhancementMetadata bytecodeEnhancementMetadata = sessionFactory() .getMetamodel() .entityPersister( Parent.class ) .getEntityMetamodel() .getBytecodeEnhancementMetadata(); if ( isNullExpected ) { // if a null Interceptor is expected, then there shouldn't be any uninitialized attributes assertFalse( bytecodeEnhancementMetadata.hasUnFetchedAttributes( parent ) ); assertNull( bytecodeEnhancementMetadata.extractInterceptor( parent ) ); } else { assertNotNull( bytecodeEnhancementMetadata.extractInterceptor( parent ) ); } }
@Override public void afterInitialize(Object entity, SharedSessionContractImplementor session) { // moving to multiple fetch groups, the idea of `lazyPropertiesAreUnfetched` really // needs to become either: // 1) the names of all un-fetched fetch groups // 2) the names of all fetched fetch groups // probably (2) is best // // ultimately this comes from EntityEntry, although usage-search seems to show it is never updated there. // // also org.hibernate.persister.entity.AbstractEntityPersister.initializeLazyPropertiesFromDatastore() // needs to be re-worked if ( entity instanceof PersistentAttributeInterceptable ) { final LazyAttributeLoadingInterceptor interceptor = getEntityMetamodel().getBytecodeEnhancementMetadata().extractInterceptor( entity ); if ( interceptor == null ) { getEntityMetamodel().getBytecodeEnhancementMetadata().injectInterceptor( entity, session ); } else { if ( interceptor.getLinkedSession() == null ) { interceptor.setSession( session ); } } } // clear the fields that are marked as dirty in the dirtyness tracker if ( entity instanceof SelfDirtinessTracker ) { ( (SelfDirtinessTracker) entity ).$$_hibernate_clearDirtyAttributes(); } }
.extractInterceptor( parent ); child = interceptor.fetchAttribute( parent, propertyName );
LazyAttributeLoadingInterceptor interceptor = descriptor.getBytecodeEnhancementMetadata().extractInterceptor( parent ); child = interceptor.fetchAttribute( parent, attribute.getName() );