Optimistic locking @Version annotation causes spurious update on merge() of detached objects ( but not saveOrUpdate() ) when nothing has changed

Description

A simple Parent -> Child with @OneToMany children.

If have a detached object that has zero changes from the previously saved object and you call session.merge() a spurious update is generated if the Parent has an optimistic locking @Version field.
However, no spurious update is generated if :

  • There is no @Version field

  • session.saveOrUpdate() is used instead of session.merge()

Here is the std-out to kind illustrate the issue. Note the update statement.

Here is Test case

Attachments

1

Activity

Show:

Nick Minutello May 4, 2022 at 1:18 PM
Edited

Is there any update on this issue?

Details

Assignee

Reporter

Components

Affects versions

Priority

Created May 15, 2019 at 1:27 PM
Updated November 12, 2024 at 9:54 AM