Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hibernate update only some fields [closed]

In some cases I want to update only one collumn, but I don't want to get the object from the data base and I only have it's ID and the value I want to update.

As the other values are null, the hibernate are updating then as null. I wonder some criteria to erase the other columns from the update.

I read about dynamic-update=true and its only exclude the unmodified properties. But the nulls are still there at my update.

Does anyone have any idea? Thanks! Felipe

like image 580
Felipe Gutierrez Avatar asked May 29 '14 22:05

Felipe Gutierrez


1 Answers

You have to get the object from the database, change the value and save it. If you don't want that, you have to write your own query.

like image 51
David W Lee Avatar answered Sep 19 '22 10:09

David W Lee