I'll quote the first bit of my stackoverflow post here, to get the context right. After I have posted this I've found something I believe is not right:
"I've an Spring Boot app which, of course, has entities. These entities get updated via an thymeleaf form. In this form only some relevant fields are changeable. For example the name of the entity. Other fields like, created, createdby or lastUsedBy are not controlled / changed by this form.
Now heres the problem: If we now change the entity, all other fields are set to null, because they are not in the request. One approach would be to add for these missing fields <input type="hidden"/>inputs. But this not very elegant and error prone. Than I've come to the conclusion, that hibernate should only update those fields which have been changed. So this has to be done via DirtyTracking. I've currently another app, which uses OpenJPA with the openJPA Enhancer and in this app the update only updates the changed fields. My assumption was that the Hibernate enhancer would solve my issue. But even with dirty tracking enabled all fields are updated and information gets lost. I've managed to get it working when I add the @DynamicUpdate annotation to the given entity, but this can't be the right way right?"
So. I've tested a bit further, even without the bytecode enhancing for dirty tracking and found that the
setPropertyValues method in the
AbstractEntityTuplizer gets an object array of changed values. I suspect that this method should only call the setters for those changed values but instead it calls every setter of the entity and sets the fields to null if they are not in the values parameter array.
Am I missing something here or how does this properly work?
Stackoverflow post:
http://stackoverflow.com/questions/4258 ... d-tracking