I have read in the hibernate docs that it is not allowed to use EntityManager methods from these callbacks.
Is the current ("this") entity "managed" during the execution of the @PreUpdate annotated method?
Is it allowed to change (non-transient) fields of the current (this) entity in these methods? Will these changes be stored? Will the @PreUpdate method be called again for these changes and by that create some kind of recursion?
Is it allowed to change (non-transient) fields of other entities in these methods? Accessing these other entities is done through the OO relationships of the current (this) entity.
I got some inconsistent results... In fact, changing values of fields of the current entity WORKED WELL and the fields changed in the DB, with no recursion of the @PreUpdate method. However, changing fields of other entities... well... it sometimes works and sometimes doesn't. It's as if sometimes (I have a few guesses about when) the related entities (of the one that the @PreUpdate method is invoked upon) are managed, and sometimes they are not.
Can someone direct me to a set of deterministic UNequivocal rules regarding Do-s and Don't Do-s on these entity callbacks?
Thanks!
-------------------
Amit Kasher
|