@Override public void setPropertyValues(Object entity, Object[] values) throws HibernateException { if ( !getEntityMetamodel().hasLazyProperties() && optimizer != null && optimizer.getAccessOptimizer() != null ) { setPropertyValuesWithOptimizer( entity, values ); } else { super.setPropertyValues( entity, values ); } }
@Override public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory) { if ( entityInstance == null ) { return getEntityName(); } final Class concreteEntityClass = entityInstance.getClass(); if ( concreteEntityClass == getMappedClass() ) { return getEntityName(); } else { String entityName = getEntityMetamodel().findEntityNameByEntityClass( concreteEntityClass ); if ( entityName == null ) { throw new HibernateException( "Unable to resolve entity name from Class [" + concreteEntityClass.getName() + "]" + " expected instance/subclass of [" + getEntityName() + "]" ); } return entityName; } }
@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(); } }
/** * {@inheritDoc} */ @Override public boolean hasUninitializedLazyProperties(Object entity) { if ( getEntityMetamodel().hasLazyProperties() ) { FieldInterceptor callback = FieldInterceptionHelper.extractFieldInterceptor( entity ); return callback != null && !callback.isInitialized(); } else { return false; } }
/** * {@inheritDoc} */ @Override public boolean hasUninitializedLazyProperties(Object entity) { if ( getEntityMetamodel().hasLazyProperties() ) { FieldInterceptor callback = FieldInterceptionHelper.extractFieldInterceptor( entity ); return callback != null && !callback.isInitialized(); } else { return false; } }
/** * {@inheritDoc} */ public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory) { final Class concreteEntityClass = entityInstance.getClass(); if ( concreteEntityClass == getMappedClass() ) { return getEntityName(); } else { String entityName = getEntityMetamodel().findEntityNameByEntityClass( concreteEntityClass ); if ( entityName == null ) { throw new HibernateException( "Unable to resolve entity name from Class [" + concreteEntityClass.getName() + "]" + " expected instance/subclass of [" + getEntityName() + "]" ); } return entityName; } }
/** * {@inheritDoc} */ @Override public void setPropertyValues(Object entity, Object[] values) throws HibernateException { if ( !getEntityMetamodel().hasLazyProperties() && optimizer != null && optimizer.getAccessOptimizer() != null ) { setPropertyValuesWithOptimizer( entity, values ); } else { super.setPropertyValues( entity, values ); } }
/** * {@inheritDoc} */ public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory) { final Class concreteEntityClass = entityInstance.getClass(); if ( concreteEntityClass == getMappedClass() ) { return getEntityName(); } else { String entityName = getEntityMetamodel().findEntityNameByEntityClass( concreteEntityClass ); if ( entityName == null ) { throw new HibernateException( "Unable to resolve entity name from Class [" + concreteEntityClass.getName() + "]" + " expected instance/subclass of [" + getEntityName() + "]" ); } return entityName; } }
/** * {@inheritDoc} */ @Override public void setPropertyValues(Object entity, Object[] values) throws HibernateException { if ( !getEntityMetamodel().hasLazyProperties() && optimizer != null && optimizer.getAccessOptimizer() != null ) { setPropertyValuesWithOptimizer( entity, values ); } else { super.setPropertyValues( entity, values ); } }
/** * {@inheritDoc} */ @Override public void afterInitialize(Object entity, boolean lazyPropertiesAreUnfetched, SessionImplementor session) { if ( isInstrumented() ) { Set lazyProps = lazyPropertiesAreUnfetched && getEntityMetamodel().hasLazyProperties() ? lazyPropertyNames : null; //TODO: if we support multiple fetch groups, we would need // to clone the set of lazy properties! FieldInterceptionHelper.injectFieldInterceptor( entity, getEntityName(), lazyProps, session ); } }
/** * {@inheritDoc} */ @Override public void afterInitialize(Object entity, boolean lazyPropertiesAreUnfetched, SessionImplementor session) { if ( isInstrumented() ) { Set lazyProps = lazyPropertiesAreUnfetched && getEntityMetamodel().hasLazyProperties() ? lazyPropertyNames : null; //TODO: if we support multiple fetch groups, we would need // to clone the set of lazy properties! FieldInterceptionHelper.injectFieldInterceptor( entity, getEntityName(), lazyProps, session ); } }