some cleanups to AbstractEntityInitializer

it had some really long methods
This commit is contained in:
Gavin 2022-12-24 12:15:55 +01:00 committed by Gavin King
parent 608e4ef6d6
commit b1e2eca53e
3 changed files with 532 additions and 564 deletions

View File

@ -36,8 +36,7 @@ public interface NaturalIdResolutions {
*/ */
Object removeResolution(Object id, Object naturalId, EntityMappingType entityDescriptor); Object removeResolution(Object id, Object naturalId, EntityMappingType entityDescriptor);
void cacheResolutionFromLoad( void cacheResolutionFromLoad(Object id, Object naturalId, EntityMappingType entityDescriptor);
Object id, Object naturalId, EntityMappingType entityDescriptor);
/** /**
* Ensures that the necessary local cross-reference exists. Specifically, this * Ensures that the necessary local cross-reference exists. Specifically, this

View File

@ -40,15 +40,10 @@ public class EntityInstantiatorPojoStandard extends AbstractEntityInstantiatorPo
PersistentClass persistentClass, PersistentClass persistentClass,
JavaType<?> javaType) { JavaType<?> javaType) {
super( entityMetamodel, persistentClass, javaType ); super( entityMetamodel, persistentClass, javaType );
this.entityMetamodel = entityMetamodel; this.entityMetamodel = entityMetamodel;
this.proxyInterface = persistentClass.getProxyInterface(); proxyInterface = persistentClass.getProxyInterface();
constructor = isAbstract() ? null : resolveConstructor( getMappedPojoClass() );
this.constructor = isAbstract() applyBytecodeInterception = isPersistentAttributeInterceptableType( persistentClass.getMappedClass() );
? null
: resolveConstructor( getMappedPojoClass() );
this.applyBytecodeInterception = isPersistentAttributeInterceptableType( persistentClass.getMappedClass() );
} }
protected static Constructor<?> resolveConstructor(Class<?> mappedPojoClass) { protected static Constructor<?> resolveConstructor(Class<?> mappedPojoClass) {
@ -57,10 +52,9 @@ public class EntityInstantiatorPojoStandard extends AbstractEntityInstantiatorPo
} }
catch ( PropertyNotFoundException e ) { catch ( PropertyNotFoundException e ) {
LOG.noDefaultConstructor( mappedPojoClass.getName() ); LOG.noDefaultConstructor( mappedPojoClass.getName() );
}
return null; return null;
} }
}
@Override @Override
public boolean canBeInstantiated() { public boolean canBeInstantiated() {
@ -69,27 +63,26 @@ public class EntityInstantiatorPojoStandard extends AbstractEntityInstantiatorPo
@Override @Override
protected Object applyInterception(Object entity) { protected Object applyInterception(Object entity) {
if ( !applyBytecodeInterception ) { if ( applyBytecodeInterception ) {
return entity; asPersistentAttributeInterceptable( entity )
} .$$_hibernate_setInterceptor( new LazyAttributeLoadingInterceptor(
PersistentAttributeInterceptor interceptor = new LazyAttributeLoadingInterceptor(
entityMetamodel.getName(), entityMetamodel.getName(),
null, null,
entityMetamodel.getBytecodeEnhancementMetadata() entityMetamodel.getBytecodeEnhancementMetadata()
.getLazyAttributesMetadata() .getLazyAttributesMetadata()
.getLazyAttributeNames(), .getLazyAttributeNames(),
null null
); ) );
asPersistentAttributeInterceptable( entity ).$$_hibernate_setInterceptor( interceptor ); }
return entity; return entity;
} }
@Override @Override
public boolean isInstance(Object object, SessionFactoryImplementor sessionFactory) { public boolean isInstance(Object object, SessionFactoryImplementor sessionFactory) {
return super.isInstance( object, sessionFactory ) || return super.isInstance( object, sessionFactory )
//this one needed only for guessEntityMode() //this one needed only for guessEntityMode()
( proxyInterface!=null && proxyInterface.isInstance(object) ); || proxyInterface != null && proxyInterface.isInstance( object );
} }
@Override @Override