Skip to content

EntityUpdateAction increments version despite veto on update #3198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chenhh021 opened this issue Nov 16, 2022 · 0 comments · Fixed by #3199
Closed

EntityUpdateAction increments version despite veto on update #3198

chenhh021 opened this issue Nov 16, 2022 · 0 comments · Fixed by #3199

Comments

@chenhh021
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants