HHH-13611 : Restore EntityMetamodel constructor to take SessionFactoryImplementor argument instead of PersisterCreationContext

This commit is contained in:
Gail Badner 2019-09-03 14:43:37 -07:00 committed by Andrea Boriero
parent 2076c68ddf
commit b26ec4e625
7 changed files with 16 additions and 63 deletions

View File

@ -8,7 +8,6 @@ package org.hibernate.bytecode.enhance.spi.interceptor;
import java.util.Locale;
import java.util.function.BiFunction;
import java.util.function.Function;
import org.hibernate.FlushMode;
import org.hibernate.LazyInitializationException;
@ -31,8 +30,7 @@ public class EnhancementHelper {
public static boolean includeInBaseFetchGroup(
Property bootMapping,
boolean isEnhanced,
boolean allowEnhancementAsProxy,
Function<String,Boolean> hasSubclassChecker) {
boolean allowEnhancementAsProxy) {
final Value value = bootMapping.getValue();
if ( ! isEnhanced ) {
@ -57,7 +55,6 @@ public class EnhancementHelper {
}
// include it in the base fetch group so long as the config allows
// using the FK to create an "enhancement proxy"
// return allowEnhancementAsProxy && hasSubclassChecker.apply( toOne.getReferencedEntityName() );
return allowEnhancementAsProxy;
}

View File

@ -16,7 +16,6 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
@ -34,8 +33,7 @@ public class LazyAttributesMetadata implements Serializable {
public static LazyAttributesMetadata from(
PersistentClass mappedEntity,
boolean isEnhanced,
boolean allowEnhancementAsProxy,
Function<String,Boolean> hasSubclassChecker) {
boolean allowEnhancementAsProxy) {
final Map<String, LazyAttributeDescriptor> lazyAttributeDescriptorMap = new LinkedHashMap<>();
final Map<String, Set<String>> fetchGroupToAttributesMap = new HashMap<>();
@ -48,8 +46,7 @@ public class LazyAttributesMetadata implements Serializable {
final boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
property,
isEnhanced,
allowEnhancementAsProxy,
hasSubclassChecker
allowEnhancementAsProxy
);
if ( lazy ) {
final LazyAttributeDescriptor lazyAttributeDescriptor = LazyAttributeDescriptor.from( property, i, x++ );

View File

@ -568,7 +568,7 @@ public abstract class AbstractEntityPersister
this.naturalIdRegionAccessStrategy = null;
}
this.entityMetamodel = new EntityMetamodel( persistentClass, this, creationContext );
this.entityMetamodel = new EntityMetamodel( persistentClass, this, creationContext.getSessionFactory() );
this.entityTuplizer = this.entityMetamodel.getTuplizer();
if ( entityMetamodel.isMutable() ) {
@ -704,14 +704,7 @@ public abstract class AbstractEntityPersister
final boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
prop,
entityMetamodel.isInstrumented(),
creationContext.getSessionFactory().getSessionFactoryOptions().isEnhancementAsProxyEnabled(),
associatedEntityName -> {
final PersistentClass bootEntityDescriptor = creationContext.getMetadata().getEntityBinding( associatedEntityName );
if ( bootEntityDescriptor == null ) {
return false;
}
return bootEntityDescriptor.hasSubclasses();
}
creationContext.getSessionFactory().getSessionFactoryOptions().isEnhancementAsProxyEnabled()
);
if ( lazy ) {
@ -787,14 +780,7 @@ public abstract class AbstractEntityPersister
final boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
prop,
entityMetamodel.isInstrumented(),
creationContext.getSessionFactory().getSessionFactoryOptions().isEnhancementAsProxyEnabled(),
associatedEntityName -> {
final PersistentClass bootEntityDescriptor = creationContext.getMetadata().getEntityBinding( associatedEntityName );
if ( bootEntityDescriptor == null ) {
return false;
}
return bootEntityDescriptor.hasSubclasses();
}
creationContext.getSessionFactory().getSessionFactoryOptions().isEnhancementAsProxyEnabled()
);
while ( colIter.hasNext() ) {
Selectable thing = (Selectable) colIter.next();

View File

@ -7,7 +7,6 @@
package org.hibernate.tuple;
import java.lang.reflect.Constructor;
import java.util.function.Function;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
@ -155,8 +154,7 @@ public final class PropertyFactory {
SessionFactoryImplementor sessionFactory,
int attributeNumber,
Property property,
boolean lazyAvailable,
Function<String,Boolean> hasSubclassChecker) {
boolean lazyAvailable) {
final Type type = property.getValue().getType();
final NonIdentifierAttributeNature nature = decode( type );
@ -174,8 +172,7 @@ public final class PropertyFactory {
final boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
property,
lazyAvailable,
sessionFactory.getSessionFactoryOptions().isEnhancementAsProxyEnabled(),
hasSubclassChecker
sessionFactory.getSessionFactoryOptions().isEnhancementAsProxyEnabled()
);
switch ( nature ) {

View File

@ -8,7 +8,6 @@ package org.hibernate.tuple.entity;
import java.io.Serializable;
import java.util.Set;
import java.util.function.Function;
import org.hibernate.LockMode;
import org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor;
@ -38,12 +37,11 @@ public final class BytecodeEnhancementMetadataPojoImpl implements BytecodeEnhanc
PersistentClass persistentClass,
Set<String> identifierAttributeNames,
CompositeType nonAggregatedCidMapper,
boolean allowEnhancementAsProxy,
Function<String,Boolean> hasSubclassChecker) {
boolean allowEnhancementAsProxy) {
final Class mappedClass = persistentClass.getMappedClass();
final boolean enhancedForLazyLoading = PersistentAttributeInterceptable.class.isAssignableFrom( mappedClass );
final LazyAttributesMetadata lazyAttributesMetadata = enhancedForLazyLoading
? LazyAttributesMetadata.from( persistentClass, true, allowEnhancementAsProxy, hasSubclassChecker )
? LazyAttributesMetadata.from( persistentClass, true, allowEnhancementAsProxy )
: LazyAttributesMetadata.nonEnhanced( persistentClass.getEntityName() );
return new BytecodeEnhancementMetadataPojoImpl(

View File

@ -33,7 +33,6 @@ import org.hibernate.mapping.Component;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.tuple.GenerationTiming;
import org.hibernate.tuple.IdentifierProperty;
import org.hibernate.tuple.InDatabaseValueGenerationStrategy;
@ -128,8 +127,8 @@ public class EntityMetamodel implements Serializable {
public EntityMetamodel(
PersistentClass persistentClass,
EntityPersister persister,
final PersisterCreationContext creationContext) {
this.sessionFactory = creationContext.getSessionFactory();
SessionFactoryImplementor sessionFactory) {
this.sessionFactory = sessionFactory;
name = persistentClass.getEntityName();
rootName = persistentClass.getRootClass().getEntityName();
@ -164,14 +163,7 @@ public class EntityMetamodel implements Serializable {
persistentClass,
idAttributeNames,
nonAggregatedCidMapper,
sessionFactory.getSessionFactoryOptions().isEnhancementAsProxyEnabled(),
associatedEntityName -> {
final PersistentClass bootEntityDescriptor = creationContext.getMetadata().getEntityBinding( associatedEntityName );
if ( bootEntityDescriptor == null ) {
return false;
}
return bootEntityDescriptor.hasSubclasses();
}
sessionFactory.getSessionFactoryOptions().isEnhancementAsProxyEnabled()
);
}
else {
@ -234,14 +226,7 @@ public class EntityMetamodel implements Serializable {
sessionFactory,
i,
prop,
bytecodeEnhancementMetadata.isEnhancedForLazyLoading(),
associatedEntityName -> {
final PersistentClass bootEntityDescriptor = creationContext.getMetadata().getEntityBinding( associatedEntityName );
if ( bootEntityDescriptor == null ) {
return false;
}
return bootEntityDescriptor.hasSubclasses();
}
bytecodeEnhancementMetadata.isEnhancedForLazyLoading()
);
}
@ -260,14 +245,7 @@ public class EntityMetamodel implements Serializable {
boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
prop,
bytecodeEnhancementMetadata.isEnhancedForLazyLoading(),
sessionFactory.getSessionFactoryOptions().isEnhancementAsProxyEnabled(),
associatedEntityName -> {
final PersistentClass bootEntityDescriptor = creationContext.getMetadata().getEntityBinding( associatedEntityName );
if ( bootEntityDescriptor == null ) {
return false;
}
return bootEntityDescriptor.hasSubclasses();
}
sessionFactory.getSessionFactoryOptions().isEnhancementAsProxyEnabled()
);
if ( lazy ) {

View File

@ -71,7 +71,7 @@ public class CustomPersister implements EntityPersister {
NaturalIdDataAccess naturalIdRegionAccessStrategy,
PersisterCreationContext creationContext) {
this.factory = creationContext.getSessionFactory();
this.entityMetamodel = new EntityMetamodel( model, this, creationContext );
this.entityMetamodel = new EntityMetamodel( model, this, creationContext.getSessionFactory() );
}
public boolean hasLazyProperties() {