Home » Support » Forum » Bug with unique constraint exception not resulting in transaction roll back

Bug with unique constraint exception not resulting in transaction roll back

#1

I'm using ObjectDB 2.5.6_02 and running into a bug with a JDO @Unique constraint.  I'm using JPA in general. I have an EJB persisting two entities with @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) declared on the EJB method.  The two entities have the same value for the field with the @Unique constraint.

The unique constraint causes an exception as expected, but I would expect ObjectDB to roll back the transaction and not persist anything.  However, it is persisting both entities.

#2

This could happen if the operation is spread over more than one transaction.

In a managed environment, in which transactions are started and committed by the application server and not be the application, sometimes it is difficult to see when one transaction is ended and another one begins.

if you are sure that there is a problem, you may try to isolate it by forming a minimal application that demonstrates the problem, and then post that test case.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#3

Removing @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) on my method does result in a transaction rollback as expected.   However, this same method is where the persistence is happening, and so I think the transaction should not be committed no matter what the TransactionAttribute is.

I'll work on creating a simple test case and then create an issue.

Thanks for your help.


Post Reply

To post a reply and/or subscribe to update notifications - please login