Im using eclipselink with jpa and when I do commit sometimes im having error with lack of info , there is a way get addtional informative error which can help me to find the cause of the error quickly ?
entityManager.getTransaction().commit();
Im using eclipselink with jpa and when I do commit sometimes im having error with lack of info , there is a way get addtional informative error which can help me to find the cause of the error quickly ?
entityManager.getTransaction().commit();
This is a typical case when the commit itself fails.
Most typically when there is a constraint in the database, what is not known by the JPA layer.
For example on your database table column you might have a unique constraint which is not defined in JPA, in this case the commit will throw an error.
So my suggestion is checking the possibility of database constraint violations.
In addition you should catch a javax.transaction.RollbackException
around your transaction:
try {
entityManager.getTransaction().begin();
...
entityManager.getTransaction().commit();
} catch (RollbackException e1) {
System.out.println(e1.getMessage());
System.out.println(e1.getCause());
throw ...;
}
The e1.getCause()
should contain the violated constraint. At least when using a civilized database and JDBC driver :).