@UpdateTimestamp behavior change between Hibernate 5.6 and 6.6

Recently we noticed a change in behavior when we use Hibernate’s @UpdateTimestamp to update the last modified date for entities that also use optimistic locking.

In Hibernate 6.6, @UpdateTimestamp has no effect if only a @ManyToMany relationship is changed on the owner side. The @Version attribute is incremented, but the modification date remains the same.

We have tested the following versions: 5.6.15, 6.6.4, 6.6.20, 7.0.7

In Hibernate 5.6, @UpdateTimestamp is executed when relationships are changed on the owner side.

The behavior change also applies to @ElementCollections with maps.
Changes for @Basic attributes and versioning with @Version are not affected.

Was this change intentional? We can provide unit tests to verify the behavior change.

As far as I can tell, any change to an owned collection should trigger an optimistic version increment and hence also run update generators, so unless I misunderstood your use case, this sounds like a bug to me.
Please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer.

Thanks @beikov, HHH-19640 contains the issue description and the link to the reproducer.

1 Like