How can I prevent Hibernate from updating NULL values

前端 未结 3 770
执笔经年
执笔经年 2021-02-01 06:10

Is there a setting in hibernate to ignore null values of properties when saving a hibernate object?

NOTE
In my case I am de-serial

3条回答
  •  借酒劲吻你
    2021-02-01 06:39

    You should first load the object using the primary key from DB and then copy or deserialize the JSON on top of it.

    There is no way for hibernate to figure out whether a property with value null has been explicitly set to that value or it was excluded.

    If it is an insert then dynamic-insert=true should work.

提交回复
热议问题