What is the best practice for updating a model where only certain fields are meant to be updated?
Eg.
If I have a person model with:
Name Birthdate Address
And a form where I want to update only:
Address
The two options I can currently see are:
I'd prefer to make use of the hibernate model if possible, so I'm using #1 currently.
Is there a better way?
How Hibernate constructs an SQL Update can be configured to update only the fields that changed, using an attribute called dynamic-update
on the class mapping.
If hibernate leaves useful-looking functionality like this deactivated by default it's because there are trade-offs to be made. The linked documentation goes on to say:
The dynamic-update and dynamic-insert settings are not inherited by subclasses, so they can also be specified on the or elements. Although these settings can increase performance in some cases, they can actually decrease performance in others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With