Skip to content

Commit

Permalink
HHH-10433 - Fix hbm2ddl utils has a problem - release jdbc connection
Browse files Browse the repository at this point in the history
  • Loading branch information
dreab8 committed Jan 13, 2016
1 parent a982b56 commit 8dd86a2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
Expand Up @@ -130,7 +130,12 @@ public void execute(Target target) {
);
}

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) {
Expand Down
Expand Up @@ -86,9 +86,13 @@ public void validate() {
"Error creating DatabaseInformation for schema validation"
);
}

serviceRegistry.getService( SchemaManagementTool.class ).getSchemaValidator( cfgService.getSettings() )
.doValidation( metadata, databaseInformation );
try {
serviceRegistry.getService( SchemaManagementTool.class ).getSchemaValidator( cfgService.getSettings() )
.doValidation( metadata, databaseInformation );
}
finally {
databaseInformation.cleanup();
}
}

public static void main(String[] args) {
Expand Down
Expand Up @@ -152,4 +152,9 @@ public SequenceInformation locateSequenceInformation(QualifiedSequenceName seque

return sequenceInformationMap.get( sequenceName );
}

@Override
public void cleanup() {
extractionContext.cleanup();
}
}
Expand Up @@ -96,6 +96,7 @@ public DatabaseObjectAccess getDatabaseObjectAccess() {
return registeredTableAccess;
}

@Override
public void cleanup() {
if ( jdbcDatabaseMetaData != null ) {
jdbcDatabaseMetaData = null;
Expand Down
Expand Up @@ -101,4 +101,6 @@ public SequenceInformation getSequenceInformation(
* @return {@code true} indicates a catalog with the given name already exists
*/
boolean catalogExists(Identifier catalog);

void cleanup();
}
Expand Up @@ -40,4 +40,6 @@ interface DatabaseObjectAccess {
}

DatabaseObjectAccess getDatabaseObjectAccess();

void cleanup();
}

0 comments on commit 8dd86a2

Please sign in to comment.