|
|
|
Re: Validation on preUpdate checks unchanged entities [message #1064442 is a reply to message #1064299] |
Wed, 19 June 2013 09:47 |
Dirk Weil Messages: 8 Registered: June 2013 |
Junior Member |
|
|
I'm using Bean Validation. So I am doing nothing special, especially no explicit registration for any event.
Here is a code snippet reproducing the effect:
EntityManager entityManager = Persistence.createEntityManagerFactory("unittest").createEntityManager();
entityManager.getTransaction().begin();
List<Fragebogen> frageboegen = entityManager.createQuery("select f from Fragebogen f", Fragebogen.class).getResultList();
entityManager.getTransaction().commit();
Fragebogen is a simple entity class without any lifecycle methods. Thera are no global entity listeners as well.
Due to historic reasons some existing database entries for Fragebogen do not satisfy the bean validation constraints in Fragebogen. The obviously unchanged objects get validated when commit is requested - and validation fails, which causes a transaction abort in the end.
It seems, that in the process of calculating changes at the end of the transaction validation is triggered even on unchanged objects.
If you ask, why there is a transaction anyway: That is because the snippet is reduced to reproduce the error. Our complete code does some updates.
[Updated on: Wed, 19 June 2013 09:49] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.25296 seconds