From 33ae0b3b9e796528023e3654226a1e747ce00688 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 18 Jan 2017 21:35:08 +0000 Subject: [PATCH] HHH-11407 - JPA + JDBC transaction - when a commit fails rollback is executed twice --- ...cResourceLocalTransactionCoordinatorImpl.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jdbc/internal/JdbcResourceLocalTransactionCoordinatorImpl.java b/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jdbc/internal/JdbcResourceLocalTransactionCoordinatorImpl.java index 1454e168ce..fa011d3e81 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jdbc/internal/JdbcResourceLocalTransactionCoordinatorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jdbc/internal/JdbcResourceLocalTransactionCoordinatorImpl.java @@ -250,14 +250,16 @@ public class JdbcResourceLocalTransactionCoordinatorImpl implements TransactionC @Override public void markRollbackOnly() { - if ( log.isDebugEnabled() ) { - log.debug( - "JDBC transaction marked for rollback-only (exception provided for stack trace)", - new Exception( "exception just for purpose of providing stack trace" ) - ); - } + if ( getStatus() != TransactionStatus.ROLLED_BACK && getStatus() != TransactionStatus.NOT_ACTIVE ) { + if ( log.isDebugEnabled() ) { + log.debug( + "JDBC transaction marked for rollback-only (exception provided for stack trace)", + new Exception( "exception just for purpose of providing stack trace" ) + ); + } - rollbackOnly = true; + rollbackOnly = true; + } } } }