Skip to content

EntityUpdateAction increments version despite veto on update #3198

@chenhh021

Description

@chenhh021

The EntityUpdateAction requests whether the update is vetoed by calling preUpdate(). Even if the returned value is true (the update shall NOT be executed), the nextVersion is set to the actual entity, only executing the update itself is skipped. This may affect Optimistic Locking.

The corresponding code is

public override void Execute(){
    ...
    bool veto = PreUpdate();
    ...
    if (!veto){
	persister.Update(id, state, dirtyFields, hasDirtyCollection, previousState, previousVersion, instance, null, session);
    }
    ...
    if (entry.Status == Status.Loaded || persister.IsVersionPropertyGenerated) {
	...
	// have the entity entry perform post-update processing, passing it the
	// update state and the new version (if one).
	entry.PostUpdate(instance, state, nextVersion);
    }
    ...
}

where nextVersion is the value of the Version property previously had plus one. Either the nextVersion should be the same as the previous value or the entry.postUpdate(...) must not be executed if veto is true.

I am working for PR for it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions