Skip to content

Commit d07e1be

Browse files
committed
Retrieve JDBC Connection via JdbcCoordinator (for compatibility with Hibernate 6)
Closes gh-28007
1 parent 6b1c2dc commit d07e1be

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaDialect.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -148,7 +148,7 @@ public Object beginTransaction(EntityManager entityManager, TransactionDefinitio
148148
if (isolationLevelNeeded || definition.isReadOnly()) {
149149
if (this.prepareConnection && ConnectionReleaseMode.ON_CLOSE.equals(
150150
session.getJdbcCoordinator().getLogicalConnection().getConnectionHandlingMode().getReleaseMode())) {
151-
preparedCon = session.connection();
151+
preparedCon = session.getJdbcCoordinator().getLogicalConnection().getPhysicalConnection();
152152
previousIsolationLevel = DataSourceUtils.prepareConnectionForTransaction(preparedCon, definition);
153153
}
154154
else if (isolationLevelNeeded) {
@@ -356,9 +356,9 @@ public void resetSessionState() {
356356
}
357357
if (this.needsConnectionReset &&
358358
this.session.getJdbcCoordinator().getLogicalConnection().isPhysicallyConnected()) {
359-
Connection conToReset = this.session.connection();
359+
Connection con = this.session.getJdbcCoordinator().getLogicalConnection().getPhysicalConnection();
360360
DataSourceUtils.resetConnectionAfterTransaction(
361-
conToReset, this.previousIsolationLevel, this.readOnly);
361+
con, this.previousIsolationLevel, this.readOnly);
362362
}
363363
}
364364
}
@@ -374,7 +374,7 @@ public HibernateConnectionHandle(SessionImplementor session) {
374374

375375
@Override
376376
public Connection getConnection() {
377-
return this.session.connection();
377+
return this.session.getJdbcCoordinator().getLogicalConnection().getPhysicalConnection();
378378
}
379379
}
380380

0 commit comments

Comments
 (0)