Object deletion with optimistic version field failed


passignat@...
 

On Tue, Dec 8, 2020 at 04:51 AM, Andy wrote:
with a way of reproducing it"
I'm trying ...
 
--
Stephane


Andy
 

That message says "with a way of reproducing it".


passignat@...
 

A workaround or solution is to refresh the object before delete. (I don't know enough the spec to qualify as workaround or solution)
--
Stephane


passignat@...
 

Hi,

Since I added optimistic locking, with a numeric version attribute, the deletion doesn't work.
ERROR DataNucleus.Persistence - Object with id "1" in table I18N_MESSAGE has no version set on the object in memory and you want to delete it!! Please report this bug to the developers of DataNucleus with a way of reproducing it


Object during the DeleteRequest#execute

This object seems properly loaded.

Here are the details of persistence:


when DeleteRequest gets the currentVersion Object currentVersion = op.getTransactionalVersion(); it receives null.

Object is found by query (getSingleResult), then deleted by EntityManager.remove(id)

getSingleResult => statemanagerimpl#connect => transactionalVersion=null
statemanagerimpl#setversion is never called to set the transactionalVersion

EntityManager.remove(id) => op.getTransactionalVersion = null => error occurs


regards,
--
Stephane