mirror of https://github.com/apache/openjpa.git
Exception translation when a managed transaction completion even causes an
error. git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@491994 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a255da6f65
commit
056ecf52fd
|
@ -1757,11 +1757,11 @@ public class BrokerImpl
|
|||
} catch (OpenJPAException ke) {
|
||||
if (_log.isTraceEnabled())
|
||||
_log.trace(_loc.get("end-trans-error"), ke);
|
||||
throw ke;
|
||||
throw translateManagedCompletionException(ke);
|
||||
} catch (RuntimeException re) {
|
||||
if (_log.isTraceEnabled())
|
||||
_log.trace(_loc.get("end-trans-error"), re);
|
||||
throw new StoreException(re);
|
||||
throw translateManagedCompletionException(new StoreException(re));
|
||||
} finally {
|
||||
endOperation();
|
||||
}
|
||||
|
@ -1789,11 +1789,11 @@ public class BrokerImpl
|
|||
} catch (OpenJPAException ke) {
|
||||
if (_log.isTraceEnabled())
|
||||
_log.trace(_loc.get("end-trans-error"), ke);
|
||||
throw ke;
|
||||
throw translateManagedCompletionException(ke);
|
||||
} catch (RuntimeException re) {
|
||||
if (_log.isTraceEnabled())
|
||||
_log.trace(_loc.get("end-trans-error"), re);
|
||||
throw new StoreException(re);
|
||||
throw translateManagedCompletionException(new StoreException(re));
|
||||
} finally {
|
||||
_flags &= ~FLAG_ACTIVE;
|
||||
_flags &= ~FLAG_FLUSHED;
|
||||
|
@ -1813,6 +1813,15 @@ public class BrokerImpl
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If we're in a managed transaction, use our implicit behavior exception
|
||||
* translator to translate before/afterCompletion callback errors.
|
||||
*/
|
||||
private RuntimeException translateManagedCompletionException
|
||||
(RuntimeException re) {
|
||||
return (!_managed || _extrans == null) ? re : _extrans.translate(re);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush safely, catching reentrant calls.
|
||||
*/
|
||||
|
|
|
@ -48,7 +48,7 @@ public class PersistenceExceptions
|
|||
* and {@link NonUniqueResultException} in accordance with
|
||||
* section 3.7 of the EJB 3.0 specification.
|
||||
*/
|
||||
static RuntimeExceptionTranslator getRollbackTranslator
|
||||
public static RuntimeExceptionTranslator getRollbackTranslator
|
||||
(final OpenJPAEntityManager em) {
|
||||
return new RuntimeExceptionTranslator() {
|
||||
private boolean throwing = false;
|
||||
|
|
Loading…
Reference in New Issue