Why is version incremented for non-locked entity?

I have a Parent and Child entity, both with a @Version field. The Parent is the owning side with a @ManyToOne, so the Child is loaded eargerly.

If I only lock the Parent with OPTIMISTIC_FORCE_INCREMENT and commit the transaction, then both entities have their version field incremented. Why is the Child version incremented, when its LockModeType according to the entity manager is NONE?

Im using jakarta namespaces if that makes any difference. I can’t find anywhere in the jakarta spec that descibes this behaviour.

Hello @metooo, are you perhaps cascading the lock to the child entity with org.hibernate.annotations.CascadeType#LOCK or ALL? Please share at least the mapping of the involved entities if you want us to help you further.

It was a bug in my test - as expected the NONE locked entity version was not incremented.