Skip to content

Commit 8b8d4bb

Browse files
committed
squash! HHH-19559 move management of the schema into LogicalConnectionManagedImpl
1 parent 949873b commit 8b8d4bb

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/LogicalConnectionManagedImpl.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,22 @@ private Connection acquireConnectionIfNeeded() {
8484
finally {
8585
eventHandler.jdbcConnectionAcquisitionEnd( physicalConnection );
8686
}
87-
}
88-
8987

90-
try {
91-
jdbcSessionOwner.afterObtainConnection( physicalConnection );
92-
}
93-
catch (SQLException e) {
9488
try {
95-
// given the session a chance to set the schema
96-
jdbcSessionOwner.getJdbcConnectionAccess().releaseConnection( physicalConnection );
89+
jdbcSessionOwner.afterObtainConnection( physicalConnection );
9790
}
98-
catch (SQLException re) {
99-
e.addSuppressed( re );
91+
catch (SQLException e) {
92+
try {
93+
// given the session a chance to set the schema
94+
jdbcSessionOwner.getJdbcConnectionAccess().releaseConnection( physicalConnection );
95+
}
96+
catch (SQLException re) {
97+
e.addSuppressed( re );
98+
}
99+
throw jdbcSessionOwner.getSqlExceptionHelper()
100+
.convert( e, "Error after acquiring JDBC Connection" );
100101
}
101-
throw jdbcSessionOwner.getSqlExceptionHelper()
102-
.convert( e, "Error after acquiring JDBC Connection" );
102+
103103
}
104104

105105
return physicalConnection;
@@ -181,16 +181,16 @@ public void manualReconnect(Connection suppliedConnection) {
181181
}
182182

183183
private void releaseConnection() {
184-
try {
185-
// give the session a chance to change the schema back to null
186-
jdbcSessionOwner.beforeReleaseConnection( physicalConnection );
187-
}
188-
catch (SQLException e) {
189-
log.warn( "Error before releasing JDBC connection", e );
190-
}
191-
192184
final Connection localVariableConnection = physicalConnection;
193185
if ( localVariableConnection != null ) {
186+
try {
187+
// give the session a chance to change the schema back to null
188+
jdbcSessionOwner.beforeReleaseConnection( physicalConnection );
189+
}
190+
catch (SQLException e) {
191+
log.warn( "Error before releasing JDBC connection", e );
192+
}
193+
194194
final JdbcEventHandler eventHandler = jdbcSessionOwner.getJdbcSessionContext().getEventHandler();
195195
// We need to set the connection to null before we release resources,
196196
// in order to prevent recursion into this method.

hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ public static void process(
120120
StandardConverters.BOOLEAN,
121121
false
122122
);
123-
final ExceptionHandler exceptionHandler = haltOnError ? ExceptionHandlerHaltImpl.INSTANCE : ExceptionHandlerLoggedImpl.INSTANCE;
124123

125-
final ExecutionOptions executionOptions = buildExecutionOptions(
126-
configurationValues,
127-
exceptionHandler
128-
);
124+
final ExecutionOptions executionOptions =
125+
buildExecutionOptions( configurationValues,
126+
haltOnError
127+
? ExceptionHandlerHaltImpl.INSTANCE
128+
: ExceptionHandlerLoggedImpl.INSTANCE );
129129

130130
if ( scriptActionMap != null ) {
131131
scriptActionMap.forEach(

0 commit comments

Comments
 (0)