@Singelton
class A {
@Resource
private TrsnactionSynchronizationRegistry tsr;
@TransactionAttribute(TransactionAttributeType.Required)
method () {
// here tsr.getTransactionStatus() is 0 means active
EntityClass entity = new EnityClass();
em.persist(entity);// Duplicate Key exception
em.flush();
// here tsr.getTransactionStatus() is 1 means markedForRollback;
}
In ejb singletion bean using container managed transaction and hibernate as per the code above. After running the em.persist(entity) because of Duplicate key Exception the transaction was marked for rollback. But i want to keep the transaction active , how can i avoid it or change the status of the transaction to active.