Skip to content

Commit d858586

Browse files
committed
HHH-19559 remember the initial value of the schema setting
1 parent 4f0c552 commit d858586

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,17 +716,20 @@ private String tenantSchema() {
716716
return tenantSchemaMapper == null ? null : tenantSchemaMapper.schemaName( tenantIdentifier );
717717
}
718718

719+
private transient String initialSchema;
720+
719721
@Override
720722
public void afterObtainConnection(Connection connection) throws SQLException {
721723
if ( useSchemaBasedMultiTenancy() ) {
724+
initialSchema = connection.getSchema();
722725
connection.setSchema( tenantSchema() );
723726
}
724727
}
725728

726729
@Override
727730
public void beforeReleaseConnection(Connection connection) throws SQLException {
728731
if ( useSchemaBasedMultiTenancy() ) {
729-
connection.setSchema( null );
732+
connection.setSchema( initialSchema );
730733
}
731734
}
732735

0 commit comments

Comments
 (0)