I'm using JPA for a webservice, and I'm using Merge
to update, but it updates all my object values, is there any way to perform a partial update of it?
Example, only change values that are not null?
I'm using JPA for a webservice, and I'm using Merge
to update, but it updates all my object values, is there any way to perform a partial update of it?
Example, only change values that are not null?
The merge
operation of JPA will always synchronize the entire state of the object in the database. But there is a way to accomplish what you want:
Id
using find()
of JPA session BeanUtils
to copy the non-null properties of the partially updated object produced by the service to the object loaded by find()
. Here's how to here / a>
JPA will generate the update but only the properties changed in the loaded object will have different values.