Accueil‎ > ‎

EJB Debugging Container Managed Transaction (JTA)

posted 11 Apr 2019, 02:56 by Christophe Noël
The Java Transaction API (JTA), one of the Java Enterprise Edition (Java EE) APIs, enables distributed transactions to be done across multiple X/Open XA resources in a Java environment.

JPA  provides two mechanisms for transactions. When used in Java EE JPA provides integration with JTA (Java Transaction API). JPA also provides its own EntityTransaction implementation for Java SE and for use in a non-managed mode in Java EE.

You can inject  TransactionSynchronizationRegistry and use getTransactionStatus to retrieve the status. The response is an integercorresponding to the table mapping below.

TransactionSynchronizationRegistry tsr;

In the code:


public static final intSTATUS_ACTIVE0
public static final intSTATUS_COMMITTED3
public static final intSTATUS_COMMITTING8
public static final intSTATUS_MARKED_ROLLBACK1
public static final intSTATUS_NO_TRANSACTION6
public static final intSTATUS_PREPARED2
public static final intSTATUS_PREPARING7
public static final intSTATUS_ROLLEDBACK4
public static final intSTATUS_ROLLING_BACK9
public static final intSTATUS_UNKNOWN5