This content has been marked as final.
Show 2 replies
-
1. Re: Transaction closed after constraints violation
fernando_jmt Oct 23, 2008 7:19 PM (in response to benitojuarez)That's the expected behaviour. If some exception is thrown by the database, the transaction must rollback.
What I generally do to deal with this is to mark the involved methods with @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW). -
2. Re: Transaction closed after constraints violation
benitojuarez Oct 24, 2008 11:53 AM (in response to benitojuarez)don't work
i encapsulated the creating of a single bean in a method annotated @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW). The call of this method is done in a loop and surrounded with try-catch.
At first the entities are stored, but after the constraint violating entity all following entities are not stored in database! No exception is thrown.
If i write entityManager.flush() in the called method, this causes an exception: no transaction is in progress
BJ