EJB3/DB2 Transactions not rolling back
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 l开发者_开发问答ike this? Additional information:
Server: Glassfish
Persistence manager: Toplink
Connection Pool: DB2 Universal Driver XA compliant driver.
Thanks.
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.
精彩评论