I am trying to automatically re-hash data when saved to the database using JPA.
The idea is that I have an entity that contains a list of other entities.
A has a reference to a @OneToMany "List<B> myBList"
B => has a @ManyToOne "A a"
B
‘s hashs are based only on the entity’s data.
A
‘s hash is based on the entity’s data and the hash of the list of B
‘s
If any B
is modified or created and added to A
, I want to rehash the value of A
.
However, in my PreInsert or PreUpdateEvent listener do not register any call to entityManager.save(a)
or event.getSession().save(a)
.
B
hash is properly modified by changing the Object[] state
, but using b.getA()
, modifying A
and saving it does not work.
I am starting to wonder if that is even possible to do inside of event listeners.