EJB3/DB2 Transactions not rolling back

539 views Asked by At

I have a situation where I have a tree of Entities, and a Session Bean. The Session Bean simply persists or merges the entities, and the method in question is marked as @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW).

Now in the case that a child entity fails to be persisted/merged due to (for example) a foreign key violation, or missing non-nullable field, the transaction is marked in the logs to be rolled back, and an EJBException thrown. I was expecting the whole transaction to be rolled back, but instead I am seeing the parent entity appearing in the database after the EJB session bean call has returned, despite the failure of the child entity.

Has anyone else seen behaviour like this? Additional information:

Server: Glassfish
Persistence manager: Toplink
Connection Pool: DB2 Universal Driver XA compliant driver.

Thanks.

1

There are 1 answers

0
Anthony Roy On BEST ANSWER

Looks like the connection pool in Glassfish had been set with the flag "Non Transactional Connections" enabled. This was causing the failure to roll back.