When Entity is SelectBeforeUpdate, Interceptor.onFlushDirty should not be called for unchanged object update. However, onFlushDirty is wrongly called if the Entity has ManyToOne association with JoinColumn(updatable=false)
This bug is very serious because onFlushDirty is usually used to track audit logging (who updated the record and when.) With this bug, all updates result in audit logging even when they are unchanged!
This bug has been around since Hibernate 3.5.5. I am unable to upgrade Hibernate above 3.5.4 because of this issue.
Test case attached. Note that the test succeeds if updatable = false is removed from @JoinColumn of Book.java. (So we know the @JoinColumn(updatable=false) caused the issue.)
Tested with 5.2.1 Final and the issue still exists.
Tested with 5.2.2 Final and the issue still exists.
Fixed by HHH-5908.