| The problem happens when:
- The 'enableDirtyTracking' options is true and the entity is annotated on getters and the update field has a name with an '_' as a second character.
In the attachment there's a small program that illustrates the problem. We have an entity (Garanz) with a db field N_RIS. The attribute name is nRis, the getter is getNRis(). If we update just NRis, the DefaultFlushEntityEventListener comes in play and its method dirtyCheck is called:
protected void dirtyCheck(final FlushEntityEvent event) throws HibernateException {
....
if (dirtyProperties == null) {
if (entity instanceof SelfDirtinessTracker) {
if (((SelfDirtinessTracker)entity).$$_hibernate_hasDirtyAttributes()) {
int[] dirty = persister.resolveAttributeIndexes(((SelfDirtinessTracker)entity).$$_hibernate_getDirtyAttributes());
}
The problem is that hibernate_getDirtyAttributes() contains nRis, while persister.resolveAttributeIndexes matches it with an EntityMetaModel that has a NRis name (with a capitalized 'N'). Moving annotations from getters to fields is a valid workaorund. Unfortunately sometimes this is not easy to do due to reflection considerations that our application do with the entities. Setting enableDirtyTracking is another option, and probably we'll choose this one at the moment. hibernate-test.zip |