HHH-8113 - Persistence.createEntityManagerFactory() should run schema export if JPA properties are set

This commit is contained in:
Steve Ebersole 2013-04-02 14:55:19 -05:00
parent 84520cd6e3
commit 8316367683
2 changed files with 13 additions and 0 deletions

View File

@ -816,6 +816,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
@Override
public EntityManagerFactoryImpl perform() {
hibernateConfiguration = buildHibernateConfiguration( serviceRegistry );
JpaSchemaGenerator.performGeneration( hibernateConfiguration, serviceRegistry );
SessionFactoryImplementor sessionFactory;
try {

View File

@ -116,6 +116,18 @@ public class JpaSchemaGenerator {
final List<GenerationTarget> targets = Arrays.asList( databaseTarget, scriptsTarget );
// See if native Hibernate schema generation has also been requested and warn the user if so...
final String hbm2ddl = hibernateConfiguration.getProperty( org.hibernate.cfg.AvailableSettings.HBM2DDL_AUTO );
if ( StringHelper.isNotEmpty( hbm2ddl ) ) {
log.warnf(
"Hibernate hbm2ddl-auto setting was specified [%s] in combination with JPA schema-generation; " +
"combination will likely cause trouble",
hbm2ddl
);
}
// finally, do the generation
try {