Hello all,
I'm implementing the logic about persist an entity
The problem is EntityManager does not throws any exception when I try insert a duplicate row in the database
The exception is thrown by the Ejb3Tx
¿how can i catch this exception in order to create a more descriptive exception for my model?
example :
try {
em.persist(entity)
} catch (Exception e) {
// this code never is executed!!!
}
when the program counter leaves the method the exception is thrown by ejb3tx
thanks in advance
Luis
insert may or may not happen at persist(). If you want to catch it in code, call flush() explicitly right afer persist() invocation.