Skip to content

Commit 0841dc5

Browse files
committed
Restore Hibernate ORM 5.1 compatibility in HibernateTransactionManager
Issue: SPR-17557
1 parent 15f8863 commit 0841dc5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTransactionManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,10 @@ protected void doBegin(Object transaction, TransactionDefinition definition) {
541541
// Register the Hibernate Session's JDBC Connection for the DataSource, if set.
542542
if (getDataSource() != null) {
543543
SessionImplementor sessionImpl = (SessionImplementor) session;
544-
ConnectionHolder conHolder = new ConnectionHolder(sessionImpl::connection);
544+
// The following needs to use a lambda expression instead of a method reference
545+
// for compatibility with Hibernate ORM <5.2 where connection() is defined on
546+
// SessionImplementor itself instead of on SharedSessionContractImplementor...
547+
ConnectionHolder conHolder = new ConnectionHolder(() -> sessionImpl.connection());
545548
if (timeout != TransactionDefinition.TIMEOUT_DEFAULT) {
546549
conHolder.setTimeoutInSeconds(timeout);
547550
}

0 commit comments

Comments
 (0)