HHH-10433 - Fix hbm2ddl utils has a problem - release jdbc connection

This commit is contained in:
Andrea Boriero 2016-01-13 16:13:14 +00:00
parent 977c34bb59
commit d35e29dc29
6 changed files with 23 additions and 4 deletions

View File

@ -130,7 +130,12 @@ public class SchemaUpdate {
); );
} }
schemaMigrator.doMigration( metadata, databaseInformation, true, toolTargets ); try {
schemaMigrator.doMigration( metadata, databaseInformation, true, toolTargets );
}
finally {
databaseInformation.cleanup();
}
} }
private List<org.hibernate.tool.schema.spi.Target> buildToolTargets(Target target) { private List<org.hibernate.tool.schema.spi.Target> buildToolTargets(Target target) {

View File

@ -86,9 +86,13 @@ public class SchemaValidator {
"Error creating DatabaseInformation for schema validation" "Error creating DatabaseInformation for schema validation"
); );
} }
try {
serviceRegistry.getService( SchemaManagementTool.class ).getSchemaValidator( cfgService.getSettings() ) serviceRegistry.getService( SchemaManagementTool.class ).getSchemaValidator( cfgService.getSettings() )
.doValidation( metadata, databaseInformation ); .doValidation( metadata, databaseInformation );
}
finally {
databaseInformation.cleanup();
}
} }
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -152,4 +152,9 @@ public class DatabaseInformationImpl implements DatabaseInformation, ExtractionC
return sequenceInformationMap.get( sequenceName ); return sequenceInformationMap.get( sequenceName );
} }
@Override
public void cleanup() {
extractionContext.cleanup();
}
} }

View File

@ -96,6 +96,7 @@ public class ExtractionContextImpl implements ExtractionContext {
return registeredTableAccess; return registeredTableAccess;
} }
@Override
public void cleanup() { public void cleanup() {
if ( jdbcDatabaseMetaData != null ) { if ( jdbcDatabaseMetaData != null ) {
jdbcDatabaseMetaData = null; jdbcDatabaseMetaData = null;

View File

@ -101,4 +101,6 @@ public interface DatabaseInformation {
* @return {@code true} indicates a catalog with the given name already exists * @return {@code true} indicates a catalog with the given name already exists
*/ */
boolean catalogExists(Identifier catalog); boolean catalogExists(Identifier catalog);
void cleanup();
} }

View File

@ -40,4 +40,6 @@ public interface ExtractionContext {
} }
DatabaseObjectAccess getDatabaseObjectAccess(); DatabaseObjectAccess getDatabaseObjectAccess();
void cleanup();
} }