HHH-12591 - Remove second call to Scope#setSessionFactory(SessionFactoryImplementor) from TypeConfiguration#scope(SessionFactoryImplementor,BootstrapContext)

This commit is contained in:
Andrea Boriero 2018-05-16 22:03:46 +01:00
parent 9b00aaf9a5
commit 99d630bcc2
1 changed files with 19 additions and 7 deletions

View File

@ -138,14 +138,20 @@ public class TypeConfiguration implements SessionFactoryObserver, Serializable {
}
public void scope(MetadataBuildingContext metadataBuildingContext) {
log.debugf( "Scoping TypeConfiguration [%s] to MetadataBuildingContext [%s]", this, metadataBuildingContext );
if ( log.isDebugEnabled() ) {
log.debugf(
"Scoping TypeConfiguration [%s] to MetadataBuildingContext [%s]",
this,
metadataBuildingContext
);
}
scope.setMetadataBuildingContext( metadataBuildingContext );
}
public MetamodelImplementor scope(SessionFactoryImplementor sessionFactory, BootstrapContext bootstrapContext) {
if ( log.isDebugEnabled() ) {
log.debugf( "Scoping TypeConfiguration [%s] to SessionFactoryImpl [%s]", this, sessionFactory );
scope.setSessionFactory( sessionFactory );
log.debugf( "Scoping TypeConfiguration [%s] to SessionFactory [%s]", this, sessionFactory );
}
for ( Map.Entry<String, String> importEntry : scope.metadataBuildingContext.getMetadataCollector().getImports().entrySet() ) {
if ( importMap.containsKey( importEntry.getKey() ) ) {
@ -181,13 +187,17 @@ public class TypeConfiguration implements SessionFactoryObserver, Serializable {
// Instead of allowing scope#setSessionFactory to influence this, we use the SessionFactoryObserver callback
// to handle this, allowing any SessionFactory constructor code to be able to continue to have access to the
// MetadataBuildingContext through TypeConfiguration until this callback is fired.
if ( log.isDebugEnabled() ) {
log.tracef( "Handling #sessionFactoryCreated from [%s] for TypeConfiguration", factory );
}
scope.setMetadataBuildingContext( null );
}
@Override
public void sessionFactoryClosed(SessionFactory factory) {
if ( log.isDebugEnabled() ) {
log.tracef( "Handling #sessionFactoryClosed from [%s] for TypeConfiguration", factory );
}
TypeConfigurationRegistry.INSTANCE.deregisterTypeConfiguration( this );
@ -288,7 +298,9 @@ public class TypeConfiguration implements SessionFactoryObserver, Serializable {
}
public void unsetSessionFactory(SessionFactory factory) {
if ( log.isDebugEnabled() ) {
log.debugf( "Un-scoping TypeConfiguration [%s] from SessionFactory [%s]", this, factory );
}
this.sessionFactory = null;
}