HHH-8284 build SessionFactory before JPASchemaGenerator use to kick off

integrators
This commit is contained in:
Brett Meyer 2013-09-04 23:16:00 -04:00
parent 6963dc88d0
commit a5705e011e
1 changed files with 14 additions and 1 deletions

View File

@ -812,7 +812,18 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
@Override @Override
public Object perform() { public Object perform() {
final Configuration hibernateConfiguration = buildHibernateConfiguration( serviceRegistry ); final Configuration hibernateConfiguration = buildHibernateConfiguration( serviceRegistry );
// This seems overkill, but building the SF is necessary to get the Integrators to kick in.
// Metamodel will clean this up...
try {
hibernateConfiguration.buildSessionFactory( serviceRegistry );
}
catch (MappingException e) {
throw persistenceException( "Unable to build Hibernate SessionFactory", e );
}
JpaSchemaGenerator.performGeneration( hibernateConfiguration, serviceRegistry ); JpaSchemaGenerator.performGeneration( hibernateConfiguration, serviceRegistry );
return null; return null;
} }
} }
@ -838,7 +849,6 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
@Override @Override
public EntityManagerFactoryImpl perform() { public EntityManagerFactoryImpl perform() {
hibernateConfiguration = buildHibernateConfiguration( serviceRegistry ); hibernateConfiguration = buildHibernateConfiguration( serviceRegistry );
JpaSchemaGenerator.performGeneration( hibernateConfiguration, serviceRegistry );
SessionFactoryImplementor sessionFactory; SessionFactoryImplementor sessionFactory;
try { try {
@ -848,6 +858,9 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
throw persistenceException( "Unable to build Hibernate SessionFactory", e ); throw persistenceException( "Unable to build Hibernate SessionFactory", e );
} }
// must do after buildSessionFactory to let the Integrators kick in
JpaSchemaGenerator.performGeneration( hibernateConfiguration, serviceRegistry );
if ( suppliedSessionFactoryObserver != null ) { if ( suppliedSessionFactoryObserver != null ) {
sessionFactory.addObserver( suppliedSessionFactoryObserver ); sessionFactory.addObserver( suppliedSessionFactoryObserver );
} }