I am using JPA and @Version attribute for a Database Entity Object.
The fact is that I have a field "ENTITY_VERSION" at DB mapped to @Version, but also i have this ENTITY_VERSION in a xml representing all the object in a blob type.
The @Version value is self-created right after the record persisted : So, the xml will always be dirty ....
For example:
- First Save the xml object "x" (entity is saved with version 1, for example)
- Persist the object "x" (Version -ENTITY_VERSION - automatically is put 2).
- In the table object x will have the ENTITY_VERSION field to 2, but for the xml to "1"
I tried to update the xml using @PrePersist, getting the value of @Version , but always the value is the old one.
Is anyway to get the @Version value before persist??