Retrieve JDBC Connection via JdbcCoordinator (for compatibility with Hibernate 6)

Closes gh-28007
This commit is contained in:
Juergen Hoeller 2022-02-04 22:24:50 +01:00
parent 6b1c2dc944
commit d07e1be623
1 changed files with 5 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -148,7 +148,7 @@ public class HibernateJpaDialect extends DefaultJpaDialect {
if (isolationLevelNeeded || definition.isReadOnly()) {
if (this.prepareConnection && ConnectionReleaseMode.ON_CLOSE.equals(
session.getJdbcCoordinator().getLogicalConnection().getConnectionHandlingMode().getReleaseMode())) {
preparedCon = session.connection();
preparedCon = session.getJdbcCoordinator().getLogicalConnection().getPhysicalConnection();
previousIsolationLevel = DataSourceUtils.prepareConnectionForTransaction(preparedCon, definition);
}
else if (isolationLevelNeeded) {
@ -356,9 +356,9 @@ public class HibernateJpaDialect extends DefaultJpaDialect {
}
if (this.needsConnectionReset &&
this.session.getJdbcCoordinator().getLogicalConnection().isPhysicallyConnected()) {
Connection conToReset = this.session.connection();
Connection con = this.session.getJdbcCoordinator().getLogicalConnection().getPhysicalConnection();
DataSourceUtils.resetConnectionAfterTransaction(
conToReset, this.previousIsolationLevel, this.readOnly);
con, this.previousIsolationLevel, this.readOnly);
}
}
}
@ -374,7 +374,7 @@ public class HibernateJpaDialect extends DefaultJpaDialect {
@Override
public Connection getConnection() {
return this.session.connection();
return this.session.getJdbcCoordinator().getLogicalConnection().getPhysicalConnection();
}
}