further reduce direct use of SessionFactory during metamodel building
This commit is contained in:
parent
102ef2f469
commit
822153948c
|
@ -105,7 +105,7 @@ public class TemporaryTable implements Exportable, Contributable {
|
|||
else {
|
||||
tableNameIdentifier = new Identifier( temporaryTableName, nameParts.getObjectName().isQuoted() );
|
||||
}
|
||||
this.qualifiedTableName = creationContext.getSessionFactory().getSqlStringGenerationContext().format(
|
||||
this.qualifiedTableName = creationContext.getSqlStringGenerationContext().format(
|
||||
new QualifiedTableName(
|
||||
adjustedNameParts.getCatalogName() != null
|
||||
? adjustedNameParts.getCatalogName()
|
||||
|
|
|
@ -108,6 +108,7 @@ import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
|||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.ExceptionMapper;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
|
||||
import org.hibernate.service.spi.SessionFactoryServiceRegistryFactory;
|
||||
|
@ -321,6 +322,16 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
|
|||
public JdbcServices getJdbcServices() {
|
||||
return jdbcServices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlStringGenerationContext getSqlStringGenerationContext() {
|
||||
return sqlStringGenerationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistry getServiceRegistry() {
|
||||
return serviceRegistry;
|
||||
}
|
||||
};
|
||||
|
||||
// this needs to happen after persisters are all ready to go...
|
||||
|
|
|
@ -498,12 +498,12 @@ public class Property implements Serializable, MetaAttributable {
|
|||
|
||||
@Override
|
||||
public String getDefaultCatalog() {
|
||||
return context.getSessionFactory().getSessionFactoryOptions().getDefaultCatalog();
|
||||
return context.getSessionFactoryOptions().getDefaultCatalog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultSchema() {
|
||||
return context.getSessionFactory().getSessionFactoryOptions().getDefaultSchema();
|
||||
return context.getSessionFactoryOptions().getDefaultSchema();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,18 +62,9 @@ public class EmbeddableRepresentationStrategyPojo extends AbstractEmbeddableRepr
|
|||
|
||||
assert bootDescriptor.getComponentClass() != null;
|
||||
|
||||
this.strategySelector = creationContext.getSessionFactory()
|
||||
.getServiceRegistry()
|
||||
.getService( StrategySelector.class );
|
||||
this.strategySelector = creationContext.getServiceRegistry().getService( StrategySelector.class );
|
||||
|
||||
this.reflectionOptimizer = buildReflectionOptimizer( bootDescriptor, creationContext );
|
||||
final ConfigurationService configurationService = creationContext.getMetadata().getMetadataBuildingOptions().getServiceRegistry()
|
||||
.getService(ConfigurationService.class);
|
||||
boolean createEmptyCompositesEnabled = ConfigurationHelper.getBoolean(
|
||||
Environment.CREATE_EMPTY_COMPOSITES_ENABLED,
|
||||
configurationService.getSettings(),
|
||||
false
|
||||
);
|
||||
|
||||
this.instantiator = customInstantiator != null
|
||||
? customInstantiator
|
||||
|
@ -108,13 +99,12 @@ public class EmbeddableRepresentationStrategyPojo extends AbstractEmbeddableRepr
|
|||
}
|
||||
|
||||
if ( bootDescriptor.isEmbedded() && ReflectHelper.isAbstractClass( bootDescriptor.getComponentClass() ) ) {
|
||||
final ProxyFactoryFactory proxyFactoryFactory = creationContext.getSessionFactory()
|
||||
.getServiceRegistry()
|
||||
.getService( ProxyFactoryFactory.class );
|
||||
return new EmbeddableInstantiatorProxied(
|
||||
bootDescriptor.getComponentClass(),
|
||||
runtimeDescriptorAccess,
|
||||
proxyFactoryFactory.buildBasicProxyFactory( bootDescriptor.getComponentClass() )
|
||||
creationContext.getServiceRegistry()
|
||||
.getService( ProxyFactoryFactory.class )
|
||||
.buildBasicProxyFactory( bootDescriptor.getComponentClass() )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,9 +80,7 @@ public class EntityRepresentationStrategyPojoStandard implements EntityRepresent
|
|||
PersistentClass bootDescriptor,
|
||||
EntityPersister runtimeDescriptor,
|
||||
RuntimeModelCreationContext creationContext) {
|
||||
final SessionFactoryImplementor sessionFactory = creationContext.getSessionFactory();
|
||||
final JavaTypeRegistry jtdRegistry = creationContext.getTypeConfiguration()
|
||||
.getJavaTypeRegistry();
|
||||
final JavaTypeRegistry jtdRegistry = creationContext.getTypeConfiguration().getJavaTypeRegistry();
|
||||
|
||||
final Class<?> mappedJavaType = bootDescriptor.getMappedClass();
|
||||
this.mappedJtd = jtdRegistry.resolveEntityTypeDescriptor( mappedJavaType );
|
||||
|
@ -156,13 +154,13 @@ public class EntityRepresentationStrategyPojoStandard implements EntityRepresent
|
|||
this.proxyFactory = proxyFactory;
|
||||
|
||||
// resolveReflectionOptimizer may lead to a makePropertyAccess call which requires strategySelector
|
||||
this.strategySelector = sessionFactory.getServiceRegistry().getService( StrategySelector.class );
|
||||
this.strategySelector = creationContext.getServiceRegistry().getService( StrategySelector.class );
|
||||
final Map<String, PropertyAccess> propertyAccessMap = new LinkedHashMap<>();
|
||||
for ( Property property : bootDescriptor.getPropertyClosure() ) {
|
||||
propertyAccessMap.put( property.getName(), makePropertyAccess( property ) );
|
||||
}
|
||||
this.propertyAccessMap = propertyAccessMap;
|
||||
this.reflectionOptimizer = resolveReflectionOptimizer( bootDescriptor, bytecodeProvider, sessionFactory );
|
||||
this.reflectionOptimizer = resolveReflectionOptimizer( bytecodeProvider );
|
||||
|
||||
this.instantiator = determineInstantiator( bootDescriptor, entityMetamodel );
|
||||
}
|
||||
|
@ -268,9 +266,10 @@ public class EntityRepresentationStrategyPojoStandard implements EntityRepresent
|
|||
? null
|
||||
: ReflectHelper.getMethod( proxyInterface, idSetterMethod );
|
||||
|
||||
ProxyFactory pf = bytecodeProvider.getProxyFactoryFactory().buildProxyFactory( creationContext.getSessionFactory() );
|
||||
final ProxyFactory proxyFactory = bytecodeProvider.getProxyFactoryFactory()
|
||||
.buildProxyFactory( creationContext.getSessionFactory() );
|
||||
try {
|
||||
pf.postInstantiate(
|
||||
proxyFactory.postInstantiate(
|
||||
bootDescriptor.getEntityName(),
|
||||
mappedClass,
|
||||
proxyInterfaces,
|
||||
|
@ -281,7 +280,7 @@ public class EntityRepresentationStrategyPojoStandard implements EntityRepresent
|
|||
null
|
||||
);
|
||||
|
||||
return pf;
|
||||
return proxyFactory;
|
||||
}
|
||||
catch (HibernateException he) {
|
||||
LOG.unableToCreateProxyFactory( bootDescriptor.getEntityName(), he );
|
||||
|
@ -289,10 +288,7 @@ public class EntityRepresentationStrategyPojoStandard implements EntityRepresent
|
|||
}
|
||||
}
|
||||
|
||||
private ReflectionOptimizer resolveReflectionOptimizer(
|
||||
PersistentClass bootType,
|
||||
BytecodeProvider bytecodeProvider,
|
||||
SessionFactoryImplementor sessionFactory) {
|
||||
private ReflectionOptimizer resolveReflectionOptimizer(BytecodeProvider bytecodeProvider) {
|
||||
if ( ! Environment.useReflectionOptimizer() ) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.hibernate.engine.FetchTiming;
|
|||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.mapping.Any;
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.mapping.Column;
|
||||
|
@ -223,9 +222,8 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType
|
|||
Consumer<AttributeMapping> attributeConsumer,
|
||||
SuccessfulCompletionCallback completionCallback,
|
||||
MappingModelCreationProcess creationProcess) {
|
||||
final SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
final TypeConfiguration typeConfiguration = sessionFactory.getTypeConfiguration();
|
||||
final JdbcServices jdbcServices = sessionFactory.getJdbcServices();
|
||||
final TypeConfiguration typeConfiguration = creationProcess.getCreationContext().getTypeConfiguration();
|
||||
final JdbcServices jdbcServices = creationProcess.getCreationContext().getJdbcServices();
|
||||
final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment();
|
||||
final Dialect dialect = jdbcEnvironment.getDialect();
|
||||
|
||||
|
@ -332,42 +330,10 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType
|
|||
final boolean updateable = value.isColumnUpdateable( 0 );
|
||||
final boolean includeInOptimisticLocking = bootPropertyDescriptor.isOptimisticLocked();
|
||||
final CascadeStyle cascadeStyle = compositeType.getCascadeStyle( attributeIndex );
|
||||
final MutabilityPlan<?> mutabilityPlan;
|
||||
|
||||
if ( updateable ) {
|
||||
mutabilityPlan = new MutabilityPlan<>() {
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object deepCopy(Object value) {
|
||||
if ( value == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return anyType.deepCopy( value, creationProcess.getCreationContext().getSessionFactory() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable disassemble(Object value, SharedSessionContract session) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object assemble(Serializable cached, SharedSessionContract session) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
mutabilityPlan = ImmutableMutabilityPlan.INSTANCE;
|
||||
}
|
||||
|
||||
SimpleAttributeMetadata attributeMetadataAccess = new SimpleAttributeMetadata(
|
||||
propertyAccess,
|
||||
mutabilityPlan,
|
||||
getMutabilityPlan( updateable ),
|
||||
nullable,
|
||||
insertable,
|
||||
updateable,
|
||||
|
@ -392,7 +358,7 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType
|
|||
}
|
||||
else if ( subtype instanceof CompositeType ) {
|
||||
final CompositeType subCompositeType = (CompositeType) subtype;
|
||||
final int columnSpan = subCompositeType.getColumnSpan( sessionFactory );
|
||||
final int columnSpan = subCompositeType.getColumnSpan( creationProcess.getCreationContext().getMetadata() );
|
||||
final String subTableExpression;
|
||||
final String[] subRootTableKeyColumnNames;
|
||||
if ( rootTableKeyColumnNames == null ) {
|
||||
|
@ -476,4 +442,33 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static MutabilityPlan<?> getMutabilityPlan(boolean updateable) {
|
||||
if ( updateable ) {
|
||||
return new MutabilityPlan<>() {
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object deepCopy(Object value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable disassemble(Object value, SharedSessionContract session) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object assemble(Serializable cached, SharedSessionContract session) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
return ImmutableMutabilityPlan.INSTANCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,9 +63,8 @@ public class DiscriminatedAssociationMapping implements MappingType, FetchOption
|
|||
AnyType anyType,
|
||||
Any bootValueMapping,
|
||||
MappingModelCreationProcess creationProcess) {
|
||||
final SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
|
||||
final Dialect dialect = sessionFactory.getSqlStringGenerationContext().getDialect();
|
||||
final Dialect dialect = creationProcess.getCreationContext().getDialect();
|
||||
final String tableName = MappingModelCreationHelper.getTableIdentifierExpression(
|
||||
bootValueMapping.getTable(),
|
||||
creationProcess
|
||||
|
@ -126,7 +125,7 @@ public class DiscriminatedAssociationMapping implements MappingType, FetchOption
|
|||
? FetchTiming.DELAYED
|
||||
: FetchTiming.IMMEDIATE,
|
||||
bootValueMapping.getMetaValues(),
|
||||
sessionFactory
|
||||
creationProcess.getCreationContext().getSessionFactory()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import java.util.function.BiConsumer;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.mapping.Any;
|
||||
import org.hibernate.mapping.IndexedConsumer;
|
||||
|
@ -50,7 +49,6 @@ import org.hibernate.type.descriptor.java.JavaType;
|
|||
*/
|
||||
public class DiscriminatedCollectionPart implements DiscriminatedAssociationModelPart, CollectionPart {
|
||||
private final Nature nature;
|
||||
private final SessionFactoryImplementor sessionFactory;
|
||||
|
||||
private final NavigableRole partRole;
|
||||
private final CollectionPersister collectionDescriptor;
|
||||
|
@ -75,8 +73,6 @@ public class DiscriminatedCollectionPart implements DiscriminatedAssociationMode
|
|||
bootValueMapping,
|
||||
creationProcess
|
||||
);
|
||||
|
||||
sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.hibernate.engine.config.spi.ConfigurationService;
|
|||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
import org.hibernate.mapping.AggregateColumn;
|
||||
|
@ -168,20 +167,14 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
|
|||
this.embeddableJtd = representationStrategy.getMappedJavaType();
|
||||
this.valueMapping = embeddedPartBuilder.apply( this );
|
||||
|
||||
final ConfigurationService cs = creationContext.getSessionFactory().getServiceRegistry()
|
||||
.getService(ConfigurationService.class);
|
||||
|
||||
this.createEmptyCompositesEnabled = ConfigurationHelper.getBoolean(
|
||||
Environment.CREATE_EMPTY_COMPOSITES_ENABLED,
|
||||
cs.getSettings(),
|
||||
creationContext.getServiceRegistry().getService( ConfigurationService.class ).getSettings(),
|
||||
false
|
||||
);
|
||||
final AggregateColumn aggregateColumn = bootDescriptor.getAggregateColumn();
|
||||
if ( aggregateColumn != null ) {
|
||||
final Dialect dialect = creationContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( JdbcServices.class )
|
||||
.getDialect();
|
||||
final Dialect dialect = creationContext.getDialect();
|
||||
final boolean insertable;
|
||||
final boolean updatable;
|
||||
if ( componentProperty == null ) {
|
||||
|
@ -330,9 +323,8 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
|
|||
// );
|
||||
// todo (6.0) - get this ^^ to work, or drop the comment
|
||||
|
||||
final SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
final TypeConfiguration typeConfiguration = sessionFactory.getTypeConfiguration();
|
||||
final JdbcServices jdbcServices = sessionFactory.getJdbcServices();
|
||||
final TypeConfiguration typeConfiguration = creationProcess.getCreationContext().getTypeConfiguration();
|
||||
final JdbcServices jdbcServices = creationProcess.getCreationContext().getJdbcServices();
|
||||
final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment();
|
||||
final Dialect dialect = jdbcEnvironment.getDialect();
|
||||
|
||||
|
@ -442,42 +434,10 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
|
|||
final boolean updateable = updateability[columnPosition];
|
||||
final boolean includeInOptimisticLocking = bootPropertyDescriptor.isOptimisticLocked();
|
||||
final CascadeStyle cascadeStyle = compositeType.getCascadeStyle( attributeIndex );
|
||||
final MutabilityPlan<?> mutabilityPlan;
|
||||
|
||||
if ( updateable ) {
|
||||
mutabilityPlan = new MutabilityPlan<>() {
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object deepCopy(Object value) {
|
||||
if ( value == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return anyType.deepCopy( value, creationProcess.getCreationContext().getSessionFactory() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable disassemble(Object value, SharedSessionContract session) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object assemble(Serializable cached, SharedSessionContract session) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
mutabilityPlan = ImmutableMutabilityPlan.INSTANCE;
|
||||
}
|
||||
|
||||
SimpleAttributeMetadata attributeMetadataAccess = new SimpleAttributeMetadata(
|
||||
propertyAccess,
|
||||
mutabilityPlan,
|
||||
getMutabilityPlan( updateable ),
|
||||
nullable,
|
||||
insertable,
|
||||
updateable,
|
||||
|
@ -502,7 +462,7 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
|
|||
}
|
||||
else if ( subtype instanceof CompositeType ) {
|
||||
final CompositeType subCompositeType = (CompositeType) subtype;
|
||||
final int columnSpan = subCompositeType.getColumnSpan( sessionFactory );
|
||||
final int columnSpan = subCompositeType.getColumnSpan( creationProcess.getCreationContext().getMetadata() );
|
||||
final String subTableExpression;
|
||||
final String[] subRootTableKeyColumnNames;
|
||||
if ( rootTableKeyColumnNames == null ) {
|
||||
|
@ -589,6 +549,35 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
|
|||
return true;
|
||||
}
|
||||
|
||||
private static MutabilityPlan<?> getMutabilityPlan(boolean updateable) {
|
||||
if ( updateable ) {
|
||||
return new MutabilityPlan<>() {
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object deepCopy(Object value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable disassemble(Object value, SharedSessionContract session) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object assemble(Serializable cached, SharedSessionContract session) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
return ImmutableMutabilityPlan.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean initColumnMappings() {
|
||||
this.selectableMappings = SelectableMappingsImpl.from( this );
|
||||
return true;
|
||||
|
|
|
@ -82,7 +82,7 @@ public class IdClassEmbeddable extends AbstractEmbeddableMapping implements Iden
|
|||
this.idMapping = idMapping;
|
||||
this.virtualIdEmbeddable = virtualIdEmbeddable;
|
||||
|
||||
this.javaType = creationProcess.getCreationContext().getSessionFactory().getTypeConfiguration()
|
||||
this.javaType = creationProcess.getCreationContext().getTypeConfiguration()
|
||||
.getJavaTypeRegistry()
|
||||
.resolveManagedTypeDescriptor( idClassSource.getComponentClass() );
|
||||
|
||||
|
|
|
@ -471,7 +471,7 @@ public class ManyToManyCollectionPart extends AbstractEntityCollectionPart imple
|
|||
true,
|
||||
false,
|
||||
false,
|
||||
creationProcess.getCreationContext().getSessionFactory().getJdbcServices().getDialect(),
|
||||
creationProcess.getCreationContext().getJdbcServices().getDialect(),
|
||||
creationProcess.getSqmFunctionRegistry()
|
||||
);
|
||||
|
||||
|
@ -503,11 +503,11 @@ public class ManyToManyCollectionPart extends AbstractEntityCollectionPart imple
|
|||
collectionTableName,
|
||||
elementBootDescriptor,
|
||||
getPropertyOrder( elementBootDescriptor, creationProcess ),
|
||||
creationProcess.getCreationContext().getSessionFactory(),
|
||||
creationProcess.getCreationContext().getMetadata(),
|
||||
creationProcess.getCreationContext().getTypeConfiguration(),
|
||||
elementBootDescriptor.getColumnInsertability(),
|
||||
elementBootDescriptor.getColumnUpdateability(),
|
||||
creationProcess.getCreationContext().getSessionFactory().getJdbcServices().getDialect(),
|
||||
creationProcess.getCreationContext().getDialect(),
|
||||
creationProcess.getSqmFunctionRegistry()
|
||||
);
|
||||
|
||||
|
|
|
@ -322,12 +322,27 @@ public class MappingModelCreationHelper {
|
|||
PropertyAccess propertyAccess,
|
||||
CascadeStyle cascadeStyle,
|
||||
MappingModelCreationProcess creationProcess) {
|
||||
final MutabilityPlan mutabilityPlan;
|
||||
if ( bootProperty.isUpdateable() ) {
|
||||
mutabilityPlan = new MutabilityPlan() {
|
||||
final MutabilityPlan mutabilityPlan = getMutabilityPlan( bootProperty, attrType, creationProcess );
|
||||
return new SimpleAttributeMetadata(
|
||||
propertyAccess,
|
||||
mutabilityPlan,
|
||||
bootProperty.getValue().isNullable(),
|
||||
bootProperty.isInsertable(),
|
||||
bootProperty.isUpdateable(),
|
||||
bootProperty.isOptimisticLocked(),
|
||||
cascadeStyle
|
||||
);
|
||||
}
|
||||
|
||||
final SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext()
|
||||
.getSessionFactory();
|
||||
private static MutabilityPlan getMutabilityPlan(
|
||||
Property bootProperty,
|
||||
Type attrType,
|
||||
MappingModelCreationProcess creationProcess) {
|
||||
if ( bootProperty.isUpdateable() ) {
|
||||
return new MutabilityPlan() {
|
||||
|
||||
final SessionFactoryImplementor sessionFactory =
|
||||
creationProcess.getCreationContext().getSessionFactory();
|
||||
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
|
@ -355,16 +370,8 @@ public class MappingModelCreationHelper {
|
|||
};
|
||||
}
|
||||
else {
|
||||
mutabilityPlan = ImmutableMutabilityPlan.INSTANCE;
|
||||
return ImmutableMutabilityPlan.INSTANCE;
|
||||
}
|
||||
SimpleAttributeMetadata basicAttributeMetadataAccess = new SimpleAttributeMetadata( propertyAccess,
|
||||
mutabilityPlan,
|
||||
bootProperty.getValue().isNullable(),
|
||||
bootProperty.isInsertable(),
|
||||
bootProperty.isUpdateable(),
|
||||
bootProperty.isOptimisticLocked(),
|
||||
cascadeStyle );
|
||||
return basicAttributeMetadataAccess;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
@ -387,8 +394,7 @@ public class MappingModelCreationHelper {
|
|||
final Collection bootValueMapping = (Collection) bootProperty.getValue();
|
||||
|
||||
final RuntimeModelCreationContext creationContext = creationProcess.getCreationContext();
|
||||
final SessionFactoryImplementor sessionFactory = creationContext.getSessionFactory();
|
||||
final Dialect dialect = sessionFactory.getSqlStringGenerationContext().getDialect();
|
||||
final Dialect dialect = creationContext.getDialect();
|
||||
final MappingMetamodel domainModel = creationContext.getDomainModel();
|
||||
|
||||
final CollectionPersister collectionDescriptor = domainModel.findCollectionDescriptor( bootValueMapping.getRole() );
|
||||
|
@ -562,6 +568,7 @@ public class MappingModelCreationHelper {
|
|||
cascadeStyle
|
||||
);
|
||||
|
||||
final SessionFactoryImplementor sessionFactory = creationContext.getSessionFactory();
|
||||
final FetchStyle style = FetchOptionsHelper.determineFetchStyleByMetadata(
|
||||
fetchMode,
|
||||
collectionDescriptor.getCollectionType(),
|
||||
|
@ -996,7 +1003,7 @@ public class MappingModelCreationHelper {
|
|||
keyTableExpression,
|
||||
collectionBootValueMapping.getKey(),
|
||||
getPropertyOrder( bootValueMapping, creationProcess ),
|
||||
creationProcess.getCreationContext().getSessionFactory(),
|
||||
creationProcess.getCreationContext().getMetadata(),
|
||||
creationProcess.getCreationContext().getTypeConfiguration(),
|
||||
insertable,
|
||||
updateable,
|
||||
|
@ -1020,7 +1027,7 @@ public class MappingModelCreationHelper {
|
|||
keyTableExpression,
|
||||
bootValueMapping,
|
||||
getPropertyOrder( bootValueMapping, creationProcess ),
|
||||
creationProcess.getCreationContext().getSessionFactory(),
|
||||
creationProcess.getCreationContext().getMetadata(),
|
||||
creationProcess.getCreationContext().getTypeConfiguration(),
|
||||
insertable,
|
||||
updateable,
|
||||
|
@ -1078,7 +1085,7 @@ public class MappingModelCreationHelper {
|
|||
else {
|
||||
final EntityType entityType = (EntityType) bootValueMapping.getType();
|
||||
final Type identifierOrUniqueKeyType = entityType.getIdentifierOrUniqueKeyType(
|
||||
creationProcess.getCreationContext().getSessionFactory()
|
||||
creationProcess.getCreationContext().getMetadata()
|
||||
);
|
||||
if ( identifierOrUniqueKeyType instanceof ComponentType ) {
|
||||
componentType = (ComponentType) identifierOrUniqueKeyType;
|
||||
|
@ -1142,7 +1149,12 @@ public class MappingModelCreationHelper {
|
|||
}
|
||||
|
||||
public static String getTableIdentifierExpression(Table table, MappingModelCreationProcess creationProcess) {
|
||||
return getTableIdentifierExpression( table, creationProcess.getCreationContext().getSessionFactory() );
|
||||
if ( table.getSubselect() != null ) {
|
||||
return "( " + table.getSubselect() + " )";
|
||||
}
|
||||
|
||||
return creationProcess.getCreationContext().getSqlStringGenerationContext()
|
||||
.format( table.getQualifiedTableName() );
|
||||
}
|
||||
|
||||
public static String getTableIdentifierExpression(Table table, SessionFactoryImplementor sessionFactory) {
|
||||
|
@ -1150,7 +1162,8 @@ public class MappingModelCreationHelper {
|
|||
return "( " + table.getSubselect() + " )";
|
||||
}
|
||||
|
||||
return sessionFactory.getSqlStringGenerationContext().format( table.getQualifiedTableName() );
|
||||
return sessionFactory.getSqlStringGenerationContext()
|
||||
.format( table.getQualifiedTableName() );
|
||||
}
|
||||
|
||||
private static CollectionPart interpretMapKey(
|
||||
|
@ -1225,10 +1238,6 @@ public class MappingModelCreationHelper {
|
|||
final EntityType indexEntityType = (EntityType) collectionDescriptor.getIndexType();
|
||||
final EntityPersister associatedEntity = creationProcess.getEntityPersister( indexEntityType.getAssociatedEntityName() );
|
||||
|
||||
final EntityCollectionPart.Cardinality partCardinality = bootMapKeyDescriptor instanceof OneToMany
|
||||
? EntityCollectionPart.Cardinality.ONE_TO_MANY
|
||||
: EntityCollectionPart.Cardinality.MANY_TO_MANY;
|
||||
|
||||
final EntityCollectionPart indexDescriptor;
|
||||
if ( bootMapKeyDescriptor instanceof OneToMany ) {
|
||||
indexDescriptor = new OneToManyCollectionPart(
|
||||
|
@ -1324,8 +1333,7 @@ public class MappingModelCreationHelper {
|
|||
if ( element instanceof Any ) {
|
||||
final Any anyBootMapping = (Any) element;
|
||||
|
||||
final SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
final TypeConfiguration typeConfiguration = sessionFactory.getTypeConfiguration();
|
||||
final TypeConfiguration typeConfiguration = creationProcess.getCreationContext().getTypeConfiguration();
|
||||
final JavaTypeRegistry jtdRegistry = typeConfiguration.getJavaTypeRegistry();
|
||||
final JavaType<Object> baseJtd = jtdRegistry.getDescriptor(Object.class);
|
||||
|
||||
|
@ -1521,7 +1529,7 @@ public class MappingModelCreationHelper {
|
|||
cascadeStyle,
|
||||
creationProcess
|
||||
);
|
||||
SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
final SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
|
||||
final AssociationType type = (AssociationType) bootProperty.getType();
|
||||
final FetchStyle fetchStyle = FetchOptionsHelper
|
||||
|
@ -1571,21 +1579,14 @@ public class MappingModelCreationHelper {
|
|||
|
||||
creationProcess.registerForeignKeyPostInitCallbacks(
|
||||
"To-one key - " + navigableRole,
|
||||
() -> {
|
||||
final Dialect dialect = creationProcess.getCreationContext()
|
||||
.getSessionFactory()
|
||||
.getJdbcServices()
|
||||
.getDialect();
|
||||
|
||||
return MappingModelCreationHelper.interpretToOneKeyDescriptor(
|
||||
() -> MappingModelCreationHelper.interpretToOneKeyDescriptor(
|
||||
attributeMapping,
|
||||
bootProperty,
|
||||
(ToOne) bootProperty.getValue(),
|
||||
null,
|
||||
dialect,
|
||||
creationProcess.getCreationContext().getDialect(),
|
||||
creationProcess
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
return attributeMapping;
|
||||
}
|
||||
|
|
|
@ -52,9 +52,7 @@ public class SimpleNaturalIdMapping extends AbstractNaturalIdMapping implements
|
|||
);
|
||||
this.attribute = attribute;
|
||||
|
||||
typeConfiguration = creationProcess.getCreationContext()
|
||||
.getSessionFactory()
|
||||
.getTypeConfiguration();
|
||||
typeConfiguration = creationProcess.getCreationContext().getTypeConfiguration();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -38,13 +38,12 @@ public class VirtualIdRepresentationStrategy implements EmbeddableRepresentation
|
|||
RuntimeModelCreationContext creationContext) {
|
||||
this.entityMappingType = entityMappingType;
|
||||
if ( bootDescriptor.getComponentClassName() != null && ReflectHelper.isAbstractClass( bootDescriptor.getComponentClass() ) ) {
|
||||
final ProxyFactoryFactory proxyFactoryFactory = creationContext.getSessionFactory()
|
||||
.getServiceRegistry()
|
||||
.getService( ProxyFactoryFactory.class );
|
||||
this.instantiator = new EmbeddableInstantiatorProxied(
|
||||
bootDescriptor.getComponentClass(),
|
||||
() -> virtualIdEmbeddable,
|
||||
proxyFactoryFactory.buildBasicProxyFactory( bootDescriptor.getComponentClass() )
|
||||
creationContext.getServiceRegistry()
|
||||
.getService( ProxyFactoryFactory.class )
|
||||
.buildBasicProxyFactory( bootDescriptor.getComponentClass() )
|
||||
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi;
|
||||
|
||||
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
||||
import org.hibernate.boot.spi.BootstrapContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
|
@ -15,6 +16,7 @@ import org.hibernate.engine.jdbc.spi.JdbcServices;
|
|||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
|
@ -56,4 +58,8 @@ public interface RuntimeModelCreationContext extends PersisterCreationContext {
|
|||
SessionFactoryOptions getSessionFactoryOptions();
|
||||
|
||||
JdbcServices getJdbcServices();
|
||||
|
||||
SqlStringGenerationContext getSqlStringGenerationContext();
|
||||
|
||||
ServiceRegistry getServiceRegistry();
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ public abstract class AbstractCollectionPersister
|
|||
|
||||
this.factory = creationContext.getSessionFactory();
|
||||
this.cacheAccessStrategy = cacheAccessStrategy;
|
||||
if ( factory.getSessionFactoryOptions().isStructuredCacheEntriesEnabled() ) {
|
||||
if ( creationContext.getSessionFactoryOptions().isStructuredCacheEntriesEnabled() ) {
|
||||
cacheEntryStructure = collectionBootDescriptor.isMap()
|
||||
? StructuredMapCacheEntry.INSTANCE
|
||||
: StructuredCollectionCacheEntry.INSTANCE;
|
||||
|
@ -281,8 +281,8 @@ public abstract class AbstractCollectionPersister
|
|||
cacheEntryStructure = UnstructuredCacheEntry.INSTANCE;
|
||||
}
|
||||
|
||||
dialect = factory.getJdbcServices().getDialect();
|
||||
sqlExceptionHelper = factory.getJdbcServices().getSqlExceptionHelper();
|
||||
dialect = creationContext.getDialect();
|
||||
sqlExceptionHelper = creationContext.getJdbcServices().getSqlExceptionHelper();
|
||||
collectionType = collectionBootDescriptor.getCollectionType();
|
||||
navigableRole = new NavigableRole( collectionBootDescriptor.getRole() );
|
||||
entityName = collectionBootDescriptor.getOwnerEntityName();
|
||||
|
@ -316,8 +316,8 @@ public abstract class AbstractCollectionPersister
|
|||
sqlWhereStringTemplate = Template.renderWhereStringTemplate(
|
||||
sqlWhereString,
|
||||
dialect,
|
||||
factory.getTypeConfiguration(),
|
||||
factory.getQueryEngine().getSqmFunctionRegistry()
|
||||
creationContext.getTypeConfiguration(),
|
||||
creationContext.getFunctionRegistry()
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
@ -330,7 +330,7 @@ public abstract class AbstractCollectionPersister
|
|||
|
||||
int batch = collectionBootDescriptor.getBatchSize();
|
||||
if ( batch == -1 ) {
|
||||
batch = factory.getSessionFactoryOptions().getDefaultBatchFetchSize();
|
||||
batch = creationContext.getSessionFactoryOptions().getDefaultBatchFetchSize();
|
||||
}
|
||||
batchSize = batch;
|
||||
|
||||
|
@ -389,8 +389,8 @@ public abstract class AbstractCollectionPersister
|
|||
Formula form = (Formula) selectable;
|
||||
elementFormulaTemplates[j] = form.getTemplate(
|
||||
dialect,
|
||||
factory.getTypeConfiguration(),
|
||||
factory.getQueryEngine().getSqmFunctionRegistry()
|
||||
creationContext.getTypeConfiguration(),
|
||||
creationContext.getFunctionRegistry()
|
||||
);
|
||||
elementFormulas[j] = form.getFormula();
|
||||
}
|
||||
|
@ -401,8 +401,8 @@ public abstract class AbstractCollectionPersister
|
|||
elementColumnReaders[j] = col.getReadExpr( dialect );
|
||||
elementColumnReaderTemplates[j] = col.getTemplate(
|
||||
dialect,
|
||||
factory.getTypeConfiguration(),
|
||||
factory.getQueryEngine().getSqmFunctionRegistry()
|
||||
creationContext.getTypeConfiguration(),
|
||||
creationContext.getFunctionRegistry()
|
||||
);
|
||||
elementColumnIsGettable[j] = true;
|
||||
if ( elementType.isComponentType() ) {
|
||||
|
@ -454,8 +454,8 @@ public abstract class AbstractCollectionPersister
|
|||
Formula indexForm = (Formula) s;
|
||||
indexFormulaTemplates[i] = indexForm.getTemplate(
|
||||
dialect,
|
||||
factory.getTypeConfiguration(),
|
||||
factory.getQueryEngine().getSqmFunctionRegistry()
|
||||
creationContext.getTypeConfiguration(),
|
||||
creationContext.getFunctionRegistry()
|
||||
);
|
||||
indexFormulas[i] = indexForm.getFormula();
|
||||
hasFormula = true;
|
||||
|
@ -548,10 +548,7 @@ public abstract class AbstractCollectionPersister
|
|||
);
|
||||
}
|
||||
else if ( !elementType.isEntityType() ) {
|
||||
elementPropertyMapping = new ElementPropertyMapping(
|
||||
elementColumnNames,
|
||||
elementType
|
||||
);
|
||||
elementPropertyMapping = new ElementPropertyMapping( elementColumnNames, elementType );
|
||||
}
|
||||
else {
|
||||
// not all entity-persisters implement PropertyMapping!
|
||||
|
@ -590,9 +587,9 @@ public abstract class AbstractCollectionPersister
|
|||
manyToManyWhereString = "( " + collectionBootDescriptor.getManyToManyWhere() + ")";
|
||||
manyToManyWhereTemplate = Template.renderWhereStringTemplate(
|
||||
manyToManyWhereString,
|
||||
factory.getJdbcServices().getDialect(),
|
||||
factory.getTypeConfiguration(),
|
||||
factory.getQueryEngine().getSqmFunctionRegistry()
|
||||
creationContext.getDialect(),
|
||||
creationContext.getTypeConfiguration(),
|
||||
creationContext.getFunctionRegistry()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -624,14 +621,14 @@ public abstract class AbstractCollectionPersister
|
|||
private BeforeExecutionGenerator createGenerator(RuntimeModelCreationContext context, IdentifierCollection collection) {
|
||||
final Generator generator = collection.getIdentifier().createGenerator(
|
||||
context.getBootstrapContext().getIdentifierGeneratorFactory(),
|
||||
factory.getJdbcServices().getDialect(),
|
||||
context.getDialect(),
|
||||
null
|
||||
);
|
||||
if ( generator.generatedOnExecution() ) {
|
||||
throw new MappingException("must be an BeforeExecutionGenerator"); //TODO fix message
|
||||
}
|
||||
if ( generator instanceof IdentifierGenerator ) {
|
||||
( (IdentifierGenerator) generator ).initialize( context.getSessionFactory().getSqlStringGenerationContext() );
|
||||
( (IdentifierGenerator) generator ).initialize( context.getSqlStringGenerationContext() );
|
||||
}
|
||||
return (BeforeExecutionGenerator) generator;
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
|||
RuntimeModelCreationContext creationContext) throws MappingException, CacheException {
|
||||
super( collectionBinding, cacheAccessStrategy, creationContext );
|
||||
cascadeDeleteEnabled = collectionBinding.getKey().isCascadeDeleteEnabled()
|
||||
&& creationContext.getSessionFactory().getJdbcServices().getDialect().supportsCascadeDelete();
|
||||
&& creationContext.getDialect().supportsCascadeDelete();
|
||||
keyIsNullable = collectionBinding.getKey().isNullable();
|
||||
keyIsUpdateable = collectionBinding.getKey().isUpdateable();
|
||||
|
||||
|
|
|
@ -275,6 +275,7 @@ import org.hibernate.type.Type;
|
|||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
@ -525,12 +526,11 @@ public abstract class AbstractEntityPersister
|
|||
javaType = representationStrategy.getLoadJavaType();
|
||||
assert javaType != null;
|
||||
|
||||
final JdbcServices jdbcServices = factory.getServiceRegistry().getService( JdbcServices.class );
|
||||
final Dialect dialect = jdbcServices.getJdbcEnvironment().getDialect();
|
||||
final Dialect dialect = creationContext.getDialect();
|
||||
|
||||
int batch = persistentClass.getBatchSize();
|
||||
if ( batch == -1 ) {
|
||||
batch = factory.getSessionFactoryOptions().getDefaultBatchFetchSize();
|
||||
batch = creationContext.getSessionFactoryOptions().getDefaultBatchFetchSize();
|
||||
}
|
||||
batchSize = batch;
|
||||
hasSubselectLoadableCollections = persistentClass.hasSubselectLoadableCollections();
|
||||
|
@ -568,16 +568,17 @@ public abstract class AbstractEntityPersister
|
|||
|
||||
multiIdEntityLoader = new MultiIdLoaderStandard<>( this, persistentClass, factory );
|
||||
|
||||
SqmFunctionRegistry functionRegistry = factory.getQueryEngine().getSqmFunctionRegistry();
|
||||
final TypeConfiguration typeConfiguration = creationContext.getTypeConfiguration();
|
||||
final SqmFunctionRegistry functionRegistry = creationContext.getFunctionRegistry();
|
||||
|
||||
List<Column> columns = persistentClass.getIdentifier().getColumns();
|
||||
for ( int i = 0; i < columns.size(); i++ ) {
|
||||
for (int i = 0; i < columns.size(); i++ ) {
|
||||
Column column = columns.get(i);
|
||||
rootTableKeyColumnNames[i] = column.getQuotedName( dialect );
|
||||
rootTableKeyColumnReaders[i] = column.getReadExpr( dialect );
|
||||
rootTableKeyColumnReaderTemplates[i] = column.getTemplate(
|
||||
dialect,
|
||||
factory.getTypeConfiguration(),
|
||||
typeConfiguration,
|
||||
functionRegistry
|
||||
);
|
||||
identifierAliases[i] = column.getAlias( dialect, persistentClass.getRootTable() );
|
||||
|
@ -608,7 +609,7 @@ public abstract class AbstractEntityPersister
|
|||
sqlWhereStringTemplate = Template.renderWhereStringTemplate(
|
||||
"(" + persistentClass.getWhere() + ")",
|
||||
dialect,
|
||||
factory.getTypeConfiguration(),
|
||||
typeConfiguration,
|
||||
functionRegistry
|
||||
);
|
||||
}
|
||||
|
@ -654,7 +655,7 @@ public abstract class AbstractEntityPersister
|
|||
formula.setFormula( substituteBrackets( formula.getFormula() ) );
|
||||
formulaTemplates[k] = selectable.getTemplate(
|
||||
dialect,
|
||||
factory.getTypeConfiguration(),
|
||||
typeConfiguration,
|
||||
functionRegistry
|
||||
);
|
||||
}
|
||||
|
@ -738,7 +739,7 @@ public abstract class AbstractEntityPersister
|
|||
if ( selectable.isFormula() ) {
|
||||
final String template = selectable.getTemplate(
|
||||
dialect,
|
||||
factory.getTypeConfiguration(),
|
||||
typeConfiguration,
|
||||
functionRegistry
|
||||
);
|
||||
forms[i] = template;
|
||||
|
@ -759,7 +760,7 @@ public abstract class AbstractEntityPersister
|
|||
readers[i] = column.getReadExpr( dialect );
|
||||
readerTemplates[i] = column.getTemplate(
|
||||
dialect,
|
||||
factory.getTypeConfiguration(),
|
||||
typeConfiguration,
|
||||
functionRegistry
|
||||
);
|
||||
}
|
||||
|
@ -801,8 +802,8 @@ public abstract class AbstractEntityPersister
|
|||
? new FilterHelper( persistentClass.getFilters(), factory )
|
||||
: null;
|
||||
|
||||
useReferenceCacheEntries = shouldUseReferenceCacheEntries();
|
||||
cacheEntryHelper = buildCacheEntryHelper();
|
||||
useReferenceCacheEntries = shouldUseReferenceCacheEntries( creationContext.getSessionFactoryOptions() );
|
||||
cacheEntryHelper = buildCacheEntryHelper( creationContext.getSessionFactoryOptions() );
|
||||
invalidateCache = sessionFactoryOptions.isSecondLevelCacheEnabled()
|
||||
&& canWriteToCache
|
||||
&& shouldInvalidateCache( persistentClass, creationContext );
|
||||
|
@ -852,10 +853,10 @@ public abstract class AbstractEntityPersister
|
|||
: knownAbstract;
|
||||
}
|
||||
|
||||
private boolean shouldUseReferenceCacheEntries() {
|
||||
private boolean shouldUseReferenceCacheEntries(SessionFactoryOptions options) {
|
||||
// Check if we can use Reference Cached entities in 2lc
|
||||
// todo : should really validate that the cache access type is read-only
|
||||
if ( !factory.getSessionFactoryOptions().isDirectReferenceCacheEntriesEnabled() ) {
|
||||
if ( !options.isDirectReferenceCacheEntriesEnabled() ) {
|
||||
return false;
|
||||
}
|
||||
// for now, limit this to just entities that:
|
||||
|
@ -1097,7 +1098,7 @@ public abstract class AbstractEntityPersister
|
|||
}
|
||||
}
|
||||
|
||||
protected CacheEntryHelper buildCacheEntryHelper() {
|
||||
protected CacheEntryHelper buildCacheEntryHelper(SessionFactoryOptions options) {
|
||||
if ( cacheAccessStrategy == null ) {
|
||||
// the entity defined no caching...
|
||||
return NoopCacheEntryHelper.INSTANCE;
|
||||
|
@ -1108,7 +1109,7 @@ public abstract class AbstractEntityPersister
|
|||
return new ReferenceCacheEntryHelper( this );
|
||||
}
|
||||
else {
|
||||
return factory.getSessionFactoryOptions().isStructuredCacheEntriesEnabled()
|
||||
return options.isStructuredCacheEntriesEnabled()
|
||||
? new StructuredCacheEntryHelper( this )
|
||||
: new StandardCacheEntryHelper( this );
|
||||
}
|
||||
|
@ -4828,10 +4829,8 @@ public abstract class AbstractEntityPersister
|
|||
templateInstanceCreator = null;
|
||||
}
|
||||
else {
|
||||
final LazyValue<?> templateCreator = new LazyValue<>(
|
||||
() -> instantiator.instantiate( creationProcess.getCreationContext().getSessionFactory() )
|
||||
);
|
||||
templateInstanceCreator = templateCreator::getValue;
|
||||
final SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
templateInstanceCreator = new LazyValue<>( () -> instantiator.instantiate( sessionFactory ) )::getValue;
|
||||
}
|
||||
|
||||
identifierMapping = creationProcess.processSubPart(
|
||||
|
@ -5015,12 +5014,11 @@ public abstract class AbstractEntityPersister
|
|||
protected Map<Object, DiscriminatorValueDetails> buildDiscriminatorValueMappings(
|
||||
MappingModelCreationProcess modelCreationProcess) {
|
||||
final MappingMetamodelImplementor mappingModel =
|
||||
modelCreationProcess.getCreationContext().getSessionFactory().getMappingMetamodel();
|
||||
modelCreationProcess.getCreationContext().getDomainModel();
|
||||
//noinspection unchecked
|
||||
final JdbcLiteralFormatter<Object> jdbcLiteralFormatter =
|
||||
(JdbcLiteralFormatter<Object>) getDiscriminatorType().getJdbcLiteralFormatter();
|
||||
final Dialect dialect = modelCreationProcess.getCreationContext()
|
||||
.getSessionFactory().getJdbcServices().getDialect();
|
||||
final Dialect dialect = modelCreationProcess.getCreationContext().getDialect();
|
||||
|
||||
final Map<Object, DiscriminatorValueDetails> valueMappings = new ConcurrentHashMap<>();
|
||||
getSubclassByDiscriminatorValue().forEach( (value, entityName) -> {
|
||||
|
@ -5233,7 +5231,7 @@ public abstract class AbstractEntityPersister
|
|||
final BasicValue.Resolution<?> basicTypeResolution = bootModelVersionValue.resolve();
|
||||
|
||||
final Column column = (Column) bootModelVersionValue.getColumn();
|
||||
final Dialect dialect = creationProcess.getCreationContext().getSessionFactory().getJdbcServices().getDialect();
|
||||
final Dialect dialect = creationProcess.getCreationContext().getDialect();
|
||||
|
||||
return new EntityVersionMappingImpl(
|
||||
bootModelRootEntityDescriptor.getRootClass(),
|
||||
|
@ -5257,10 +5255,9 @@ public abstract class AbstractEntityPersister
|
|||
int stateArrayPosition,
|
||||
int fetchableIndex,
|
||||
MappingModelCreationProcess creationProcess) {
|
||||
final SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
final JdbcServices jdbcServices = sessionFactory.getJdbcServices();
|
||||
final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment();
|
||||
final Dialect dialect = jdbcEnvironment.getDialect();
|
||||
final RuntimeModelCreationContext creationContext = creationProcess.getCreationContext();
|
||||
final JdbcServices jdbcServices = creationContext.getJdbcServices();
|
||||
final Dialect dialect = creationContext.getDialect();
|
||||
|
||||
final String attrName = tupleAttrDefinition.getName();
|
||||
final Type attrType = tupleAttrDefinition.getType();
|
||||
|
@ -5336,12 +5333,12 @@ public abstract class AbstractEntityPersister
|
|||
assert !selectables.isEmpty();
|
||||
final Selectable selectable = selectables.get(0);
|
||||
|
||||
assert attrColumnExpression.equals( selectable.getText(sessionFactory.getJdbcServices().getDialect()) );
|
||||
assert attrColumnExpression.equals( selectable.getText( creationContext.getDialect() ) );
|
||||
|
||||
customReadExpr = selectable.getTemplate(
|
||||
dialect,
|
||||
sessionFactory.getTypeConfiguration(),
|
||||
sessionFactory.getQueryEngine().getSqmFunctionRegistry()
|
||||
creationContext.getTypeConfiguration(),
|
||||
creationContext.getFunctionRegistry()
|
||||
);
|
||||
customWriteExpr = selectable.getCustomWriteExpression();
|
||||
Column column = value.getColumns().get( 0 );
|
||||
|
@ -5392,9 +5389,8 @@ public abstract class AbstractEntityPersister
|
|||
);
|
||||
}
|
||||
else if ( attrType instanceof AnyType ) {
|
||||
final JavaType<Object> baseAssociationJtd = sessionFactory
|
||||
.getTypeConfiguration()
|
||||
.getJavaTypeRegistry()
|
||||
final JavaType<Object> baseAssociationJtd =
|
||||
creationContext.getTypeConfiguration().getJavaTypeRegistry()
|
||||
.getDescriptor( Object.class );
|
||||
|
||||
final AnyType anyType = (AnyType) attrType;
|
||||
|
|
|
@ -19,10 +19,10 @@ import java.util.function.Supplier;
|
|||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
||||
import org.hibernate.cache.spi.access.EntityDataAccess;
|
||||
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.internal.DynamicFilterAliasGenerator;
|
||||
|
@ -188,12 +188,10 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext );
|
||||
|
||||
final SessionFactoryImplementor factory = creationContext.getSessionFactory();
|
||||
final JdbcServices jdbcServices = factory.getServiceRegistry().getService( JdbcServices.class );
|
||||
final Dialect dialect = jdbcServices.getJdbcEnvironment().getDialect();
|
||||
final SqmFunctionRegistry functionRegistry = factory.getQueryEngine().getSqmFunctionRegistry();
|
||||
final TypeConfiguration typeConfiguration = factory.getTypeConfiguration();
|
||||
final BasicTypeRegistry basicTypeRegistry = typeConfiguration.getBasicTypeRegistry();
|
||||
final Dialect dialect = creationContext.getDialect();
|
||||
final SqmFunctionRegistry functionRegistry = creationContext.getFunctionRegistry();
|
||||
final TypeConfiguration typeConfiguration = creationContext.getTypeConfiguration();
|
||||
final BasicTypeRegistry basicTypeRegistry = creationContext.getTypeConfiguration().getBasicTypeRegistry();
|
||||
|
||||
// DISCRIMINATOR
|
||||
|
||||
|
@ -479,7 +477,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
for ( int i = 0; i < propertyClosure.size(); i++ ) {
|
||||
final String tableName =
|
||||
propertyClosure.get(i).getValue().getTable()
|
||||
.getQualifiedName( factory.getSqlStringGenerationContext() );
|
||||
.getQualifiedName( creationContext.getSqlStringGenerationContext() );
|
||||
// propertyTableNumbers[i] = getTableId( tableName, this.tableNames );
|
||||
naturalOrderPropertyTableNumbers[i] = getTableId( tableName, naturalOrderTableNames );
|
||||
}
|
||||
|
@ -495,7 +493,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
for ( Property property : persistentClass.getSubclassPropertyClosure() ) {
|
||||
final String tableName = property.getValue().getTable().
|
||||
getQualifiedName( factory.getSqlStringGenerationContext() );
|
||||
getQualifiedName( creationContext.getSqlStringGenerationContext() );
|
||||
final Integer tableNumber = getTableId( tableName, subclassTableNameClosure );
|
||||
propTableNumbers.add( tableNumber );
|
||||
|
||||
|
@ -545,7 +543,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
notNullColumnTableNumbers = new int[subclassSpan];
|
||||
final int id = getTableId(
|
||||
table.getQualifiedName( factory.getSqlStringGenerationContext() ),
|
||||
table.getQualifiedName( creationContext.getSqlStringGenerationContext() ),
|
||||
subclassTableNameClosure
|
||||
);
|
||||
notNullColumnTableNumbers[subclassSpanMinusOne] = id;
|
||||
|
@ -568,7 +566,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
initDiscriminatorProperties( dialect, k, subclassTable, discriminatorValue, isAbstract( subclass ) );
|
||||
subclassesByDiscriminatorValue.put( discriminatorValue, subclass.getEntityName() );
|
||||
final int tableId = getTableId(
|
||||
subclassTable.getQualifiedName( factory.getSqlStringGenerationContext() ),
|
||||
subclassTable.getQualifiedName( creationContext.getSqlStringGenerationContext() ),
|
||||
subclassTableNameClosure
|
||||
);
|
||||
notNullColumnTableNumbers[k] = tableId;
|
||||
|
@ -577,7 +575,10 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
}
|
||||
}
|
||||
|
||||
subclassNamesBySubclassTable = buildSubclassNamesBySubclassTableMapping( persistentClass, factory );
|
||||
subclassNamesBySubclassTable = buildSubclassNamesBySubclassTableMapping(
|
||||
persistentClass,
|
||||
creationContext.getSqlStringGenerationContext()
|
||||
);
|
||||
|
||||
initSubclassPropertyAliasesMap( persistentClass );
|
||||
|
||||
|
@ -643,7 +644,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
*/
|
||||
private String[][] buildSubclassNamesBySubclassTableMapping(
|
||||
PersistentClass persistentClass,
|
||||
SessionFactoryImplementor factory) {
|
||||
SqlStringGenerationContext context) {
|
||||
// this value represents the number of subclasses (and not the class itself)
|
||||
final int numberOfSubclassTables = subclassTableNameClosure.length - coreTableSpan;
|
||||
if ( numberOfSubclassTables == 0 ) {
|
||||
|
@ -651,15 +652,15 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
}
|
||||
|
||||
final String[][] mapping = new String[numberOfSubclassTables][];
|
||||
processPersistentClassHierarchy( persistentClass, true, factory, mapping );
|
||||
processPersistentClassHierarchy( persistentClass, true, mapping, context );
|
||||
return mapping;
|
||||
}
|
||||
|
||||
private Set<String> processPersistentClassHierarchy(
|
||||
PersistentClass persistentClass,
|
||||
boolean isBase,
|
||||
SessionFactoryImplementor factory,
|
||||
String[][] mapping) {
|
||||
String[][] mapping,
|
||||
SqlStringGenerationContext context) {
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// collect all the class names that indicate that the "main table" of the given PersistentClass should be
|
||||
|
@ -668,7 +669,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
for ( Subclass subclass : persistentClass.getDirectSubclasses() ) {
|
||||
final Set<String> subclassSubclassNames =
|
||||
processPersistentClassHierarchy( subclass, false, factory, mapping );
|
||||
processPersistentClassHierarchy( subclass, false, mapping, context );
|
||||
classNames.addAll( subclassSubclassNames );
|
||||
}
|
||||
|
||||
|
@ -681,7 +682,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
msc = msc.getSuperMappedSuperclass();
|
||||
}
|
||||
|
||||
associateSubclassNamesToSubclassTableIndexes( persistentClass, classNames, mapping, factory );
|
||||
associateSubclassNamesToSubclassTableIndexes( persistentClass, classNames, mapping, context );
|
||||
}
|
||||
|
||||
return classNames;
|
||||
|
@ -691,15 +692,13 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
PersistentClass persistentClass,
|
||||
Set<String> classNames,
|
||||
String[][] mapping,
|
||||
SessionFactoryImplementor factory) {
|
||||
SqlStringGenerationContext context) {
|
||||
|
||||
final String tableName = persistentClass.getTable()
|
||||
.getQualifiedName( factory.getSqlStringGenerationContext() );
|
||||
final String tableName = persistentClass.getTable().getQualifiedName( context );
|
||||
associateSubclassNamesToSubclassTableIndex( tableName, classNames, mapping );
|
||||
|
||||
for ( Join join : persistentClass.getJoins() ) {
|
||||
final String secondaryTableName = join.getTable()
|
||||
.getQualifiedName( factory.getSqlStringGenerationContext() );
|
||||
final String secondaryTableName = join.getTable().getQualifiedName( context );
|
||||
associateSubclassNamesToSubclassTableIndex( secondaryTableName, classNames, mapping );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.hibernate.cache.spi.access.EntityDataAccess;
|
|||
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.internal.DynamicFilterAliasGenerator;
|
||||
import org.hibernate.internal.FilterAliasGenerator;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
|
@ -143,10 +142,9 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext );
|
||||
|
||||
final SessionFactoryImplementor factory = creationContext.getSessionFactory();
|
||||
final Dialect dialect = factory.getJdbcServices().getDialect();
|
||||
final SqmFunctionRegistry functionRegistry = factory.getQueryEngine().getSqmFunctionRegistry();
|
||||
final TypeConfiguration typeConfiguration = factory.getTypeConfiguration();
|
||||
final Dialect dialect = creationContext.getDialect();
|
||||
final SqmFunctionRegistry functionRegistry = creationContext.getFunctionRegistry();
|
||||
final TypeConfiguration typeConfiguration = creationContext.getTypeConfiguration();
|
||||
|
||||
// CLASS + TABLE
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.hibernate.cache.spi.access.EntityDataAccess;
|
|||
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.id.IdentityGenerator;
|
||||
import org.hibernate.internal.FilterAliasGenerator;
|
||||
import org.hibernate.internal.StaticFilterAliasGenerator;
|
||||
|
@ -115,8 +114,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
validateGenerator();
|
||||
|
||||
final SessionFactoryImplementor factory = creationContext.getSessionFactory();
|
||||
final Dialect dialect = factory.getJdbcServices().getDialect();
|
||||
final Dialect dialect = creationContext.getDialect();
|
||||
|
||||
// TABLE
|
||||
|
||||
|
@ -162,7 +160,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
discriminatorValue = persistentClass.getSubclassId();
|
||||
discriminatorSQLValue = String.valueOf( persistentClass.getSubclassId() );
|
||||
discriminatorType = factory.getTypeConfiguration().getBasicTypeRegistry().resolve( StandardBasicTypes.INTEGER );
|
||||
discriminatorType = creationContext.getTypeConfiguration().getBasicTypeRegistry().resolve( StandardBasicTypes.INTEGER );
|
||||
|
||||
// PROPERTIES
|
||||
|
||||
|
|
|
@ -10,10 +10,8 @@ import java.util.function.BiFunction;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.internal.FastSessionServices;
|
||||
import org.hibernate.mapping.RootClass;
|
||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
||||
|
@ -50,8 +48,7 @@ public class SqmMutationStrategyHelper {
|
|||
EntityMappingType rootEntityDescriptor,
|
||||
MappingModelCreationProcess creationProcess) {
|
||||
final RuntimeModelCreationContext creationContext = creationProcess.getCreationContext();
|
||||
final SessionFactoryImplementor sessionFactory = creationContext.getSessionFactory();
|
||||
final SessionFactoryOptions options = sessionFactory.getSessionFactoryOptions();
|
||||
final SessionFactoryOptions options = creationContext.getSessionFactoryOptions();
|
||||
|
||||
final SqmMultiTableMutationStrategy specifiedStrategy = options.getCustomSqmMultiTableMutationStrategy();
|
||||
if ( specifiedStrategy != null ) {
|
||||
|
@ -60,10 +57,7 @@ public class SqmMutationStrategyHelper {
|
|||
|
||||
// todo (6.0) : add capability define strategy per-hierarchy
|
||||
|
||||
return sessionFactory.getJdbcServices()
|
||||
.getJdbcEnvironment()
|
||||
.getDialect()
|
||||
.getFallbackSqmMutationStrategy( rootEntityDescriptor, creationContext );
|
||||
return creationContext.getDialect().getFallbackSqmMutationStrategy( rootEntityDescriptor, creationContext );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,8 +69,7 @@ public class SqmMutationStrategyHelper {
|
|||
EntityMappingType rootEntityDescriptor,
|
||||
MappingModelCreationProcess creationProcess) {
|
||||
final RuntimeModelCreationContext creationContext = creationProcess.getCreationContext();
|
||||
final SessionFactoryImplementor sessionFactory = creationContext.getSessionFactory();
|
||||
final SessionFactoryOptions options = sessionFactory.getSessionFactoryOptions();
|
||||
final SessionFactoryOptions options = creationContext.getSessionFactoryOptions();
|
||||
|
||||
final SqmMultiTableInsertStrategy specifiedStrategy = options.getCustomSqmMultiTableInsertStrategy();
|
||||
if ( specifiedStrategy != null ) {
|
||||
|
@ -84,7 +77,7 @@ public class SqmMutationStrategyHelper {
|
|||
}
|
||||
|
||||
// todo (6.0) : add capability define strategy per-hierarchy
|
||||
return sessionFactory.getJdbcServices().getDialect().getFallbackSqmInsertStrategy( rootEntityDescriptor, creationContext );
|
||||
return creationContext.getDialect().getFallbackSqmInsertStrategy( rootEntityDescriptor, creationContext );
|
||||
}
|
||||
|
||||
public static void visitCollectionTables(
|
||||
|
|
|
@ -112,7 +112,7 @@ public class CteInsertStrategy implements SqmMultiTableInsertStrategy {
|
|||
this.rootDescriptor = rootDescriptor;
|
||||
this.sessionFactory = runtimeModelCreationContext.getSessionFactory();
|
||||
|
||||
final Dialect dialect = sessionFactory.getJdbcServices().getDialect();
|
||||
final Dialect dialect = runtimeModelCreationContext.getDialect();
|
||||
|
||||
if ( !dialect.supportsNonQueryWithCTE() ) {
|
||||
throw new UnsupportedOperationException(
|
||||
|
|
|
@ -9,7 +9,6 @@ package org.hibernate.query.sqm.mutation.internal.cte;
|
|||
import java.util.Locale;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
|
@ -70,7 +69,7 @@ public class CteMutationStrategy implements SqmMultiTableMutationStrategy {
|
|||
this.rootDescriptor = rootDescriptor;
|
||||
this.sessionFactory = runtimeModelCreationContext.getSessionFactory();
|
||||
|
||||
final Dialect dialect = sessionFactory.getJdbcServices().getDialect();
|
||||
final Dialect dialect = runtimeModelCreationContext.getDialect();
|
||||
|
||||
if ( !dialect.supportsNonQueryWithCTE() ) {
|
||||
throw new UnsupportedOperationException(
|
||||
|
|
|
@ -9,7 +9,6 @@ package org.hibernate.tuple.entity;
|
|||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -19,7 +18,6 @@ import java.util.Set;
|
|||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementHelper;
|
||||
import org.hibernate.bytecode.internal.BytecodeEnhancementMetadataNonPojoImpl;
|
||||
import org.hibernate.bytecode.internal.BytecodeEnhancementMetadataPojoImpl;
|
||||
|
@ -55,6 +53,7 @@ import org.hibernate.type.EntityType;
|
|||
import org.hibernate.type.ManyToOneType;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
import static org.hibernate.internal.CoreLogging.messageLogger;
|
||||
import static org.hibernate.internal.util.ReflectHelper.isAbstractClass;
|
||||
import static org.hibernate.internal.util.ReflectHelper.isFinalClass;
|
||||
|
@ -170,7 +169,8 @@ public class EntityMetamodel implements Serializable {
|
|||
|
||||
versioned = persistentClass.isVersioned();
|
||||
|
||||
SessionFactoryOptions sessionFactoryOptions = sessionFactory.getSessionFactoryOptions();
|
||||
final boolean collectionsInDefaultFetchGroupEnabled =
|
||||
creationContext.getSessionFactoryOptions().isCollectionsInDefaultFetchGroupEnabled();
|
||||
|
||||
if ( persistentClass.hasPojoRepresentation() ) {
|
||||
final Component identifierMapperComponent = persistentClass.getIdentifierMapper();
|
||||
|
@ -186,14 +186,14 @@ public class EntityMetamodel implements Serializable {
|
|||
}
|
||||
else {
|
||||
nonAggregatedCidMapper = null;
|
||||
idAttributeNames = Collections.singleton( identifierAttribute.getName() );
|
||||
idAttributeNames = singleton( identifierAttribute.getName() );
|
||||
}
|
||||
|
||||
bytecodeEnhancementMetadata = BytecodeEnhancementMetadataPojoImpl.from(
|
||||
persistentClass,
|
||||
idAttributeNames,
|
||||
nonAggregatedCidMapper,
|
||||
sessionFactoryOptions.isCollectionsInDefaultFetchGroupEnabled(),
|
||||
collectionsInDefaultFetchGroupEnabled,
|
||||
creationContext.getMetadata()
|
||||
);
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ public class EntityMetamodel implements Serializable {
|
|||
assert entityBinding != null;
|
||||
return entityBinding.hasSubclasses();
|
||||
},
|
||||
sessionFactoryOptions.isCollectionsInDefaultFetchGroupEnabled()
|
||||
collectionsInDefaultFetchGroupEnabled
|
||||
);
|
||||
|
||||
if ( lazy ) {
|
||||
|
@ -479,7 +479,7 @@ public class EntityMetamodel implements Serializable {
|
|||
}
|
||||
}
|
||||
if ( mappingProperty.getValue() instanceof Component ) {
|
||||
final Dialect dialect = context.getSessionFactory().getJdbcServices().getDialect();
|
||||
final Dialect dialect = context.getDialect();
|
||||
final CompositeGeneratorBuilder builder = new CompositeGeneratorBuilder( mappingProperty, dialect );
|
||||
final Component component = (Component) mappingProperty.getValue();
|
||||
for ( Property property : component.getProperties() ) {
|
||||
|
|
Loading…
Reference in New Issue