Entities with many-to-one properties that have insert="false" update="false" are always marked as dirty!
This is because when creating the {{ sqlSnapshotSelectString }} in {{ AbstractEntityPersister.getPropertyUpdateability() }} is used to identify which properties should be returned in that select and immutable many-to-one props are not. The {{ AbstractEntityPersister.findModified(Object[] old, Object[] current, Object entity, SessionImplementor session) }} is used to work out if the object has in fact changed , however . However {{ AbstractEntityPersister.propertyColumnUpdateable }} is always used to determine which properties are to be checked which means that immutable many-to-one properties are checked even though they're not returned by snapshot select.
This is a side effect of the change made for HHH-2350 which changed {{ ManyToOne.isAlwaysDirtyChecked }} to always return true.
So I think it should be changed so that when comparing with the DB snapshot only the properties returned by the AbstractEntityPersister.sqlSnapshotSelectString should be checked by using {{ AbstractEntityPersister.getPropertyUpdateability() }} instead of {{ AbstractEntityPersister.propertyColumnUpdateable }} |
|