WildFly (IronJacamar) - EntityManager#find with roll-back-only leads to exception rather than return null

Description

When a transaction is marked for rollback-only, IronJacamar makes the curious decision that the underlying JDBC Connection is no longer accessible. This is clearly a problem in IronJacamar/WF. However, it has been decided to
try to account for this case and still return null.

The downside to this is that we cannot always distinguish between:

  1. JDBC/SQL exception from IJ because the txn is rollback-only

  2. JDBC/SQL exception caused by real problems (aside from the few categorized exceptions)


Original description

In testing, am entityManager.find is throwing a javax.persistence.PersistenceException if JTA transaction is marked rollback only, which causes IronJacamar to throw a "javax.resource.ResourceException: IJ000459: Transaction is not active".

If we cannot find the specified entity because the database connection couldn't be obtained, I think that we should return null.

"javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection", due to IJ throwing "javax.resource.ResourceException: IJ000459: Transaction is not active: tx=Local transaction (delegate=TransactionImple < ac, BasicAction: 0:ffffac10230f:-18a11fb8:5acccf53:b64 status: ActionStatus.ABORT_ONLY >, owner=Local transaction context for provider JBoss JTA transaction provider)".

Environment

None

Status

Assignee

Steve Ebersole

Reporter

Scott Marlow

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Priority

Major
Configure