From aece331d8ac7ab4a4978c70cc86fb434fc6b90a4 Mon Sep 17 00:00:00 2001 From: Michael Dick Date: Tue, 18 Sep 2007 21:47:53 +0000 Subject: [PATCH] OPENJPA-343 merging to 1.0.x. Original changes under rev 571523 git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/1.0.x@577077 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/openjpa/kernel/BrokerImpl.java | 10 +++++++++- .../org/apache/openjpa/kernel/localizer.properties | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java index f81f66095..e0053967e 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java @@ -1430,7 +1430,15 @@ public class BrokerImpl _runtime.getTransactionManager().getTransaction(); if (trans == null) throw new InvalidStateException(_loc.get("null-trans")); - _runtime.setRollbackOnly(cause); + // ensure tran is in a valid state to accept the setRollbackOnly + int tranStatus = trans.getStatus(); + if ((tranStatus != Status.STATUS_NO_TRANSACTION) + && (tranStatus != Status.STATUS_ROLLEDBACK) + && (tranStatus != Status.STATUS_COMMITTED)) + _runtime.setRollbackOnly(cause); + else if (_log.isTraceEnabled()) + _log.trace(_loc.get("invalid-tran-status", new Integer( + tranStatus), "setRollbackOnly")); } catch (OpenJPAException ke) { throw ke; } catch (Exception e) { diff --git a/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties b/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties index fce4adb4f..cbe1dbad0 100644 --- a/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties +++ b/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties @@ -373,3 +373,5 @@ existing value assigned to this field: {0}. This existing value was either \ provided via an initializer or by calling the setter method. You either need \ to remove the @GeneratedValue annotation or modify the code to remove the \ initializer processing. +invalid-tran-status: The transaction was not in a valid state ({0}) to \ +accept the "{1}" method invocation. Processing will continue. \ No newline at end of file