Hi Ranchers (and yes ... this is a [soon to be] deprecated exam guide),
Under what possible conditions would trans still be active if JPA implementations will automatically roll back transactions if any exception is thrown during the commit process?
JPA implementations will automatically roll back transactions if any exception is thrown during the commit process.
The EntityTransaction Interface
The following example illustrates the creation of an entity manager factory in a Java SE
environment, and its use in creating and using a resource-local entity manager:
Example. Grouping Operations with Transactions:
The PersistenceException thrown by the persistence provider doesn't cause a rollback immediately. It will mark the transaction for rollback.
From JPA 2.0:
All instances of PersistenceException except for instances of NoResultException, NonUniqueResultException, LockTimeoutException, and QueryTimeoutException will cause the current transaction, if one is active, to be marked for rollback.
On particulair example for the transaction to be active (in the catch block) is when a LockTimeoutException is thrown from one of the methods in the try block.