Hi!
I have 2 entities: Parent and Child in a one-to-many relationship. The Parent is versioned, i.e. has a @Version field. My goal is to synchronize changes to both Parent and Child entities on the Parent's version.
E.g. one thread updates the Parent and another one updates one of it's Childs, this should cause an OptimisticLockException.
Is it possible?
I tried adding a @PreUpdate to the Child which would increment the version of it's Parent, but that didn't help because Hibernate seems to execute listeners only after it checks versions so the transaction commits successfully anyway.
If it is possible, how can it be implemented?