|
I have OgmEntityPersister#processInsertGeneratedProperties() and processUpdateGeneratedProperties() working, but I've hit some sort of road block.
Marking my entity's revision property with @Generated now causes it to be read back after inserts/updates as expected. But there is a problem with the following workflow:
-
Create and persist new entity -> it will have revision 1
-
Keep the entity around in detached state
-
Clear the session, do some other changes to the entity -> it will have revision 2
-
Clear the session, merge back the orginal entity in revision 1
The merge causes the entity to be loaded (with revision 2); Now as the property is marked as generated, the revision value from the detached entity isn't propgated to the tuple as to be written by the dialect -> the dialect performs the update, no optimistic locking exception occurs since the revision is the current one.
So as it seems to me, we'd need some special kind of handling of properties which are to be read back from the store after inserts/writes but still need to be propagated during writes.
@Emmanuel Bernard: Do you have any thoughts around that?
|