2

Here is custom insert sql statement example for overriding default hibernate template. Here is example of using update on duplicate key found. Is there a way to skip null values during update on duplicate? I mean that if entity already exists, it is need to update only null values. Can this situation be handled by custom @SQLInsert annotation in hibernate?

Community
  • 1
  • 1
Cherry
  • 31,309
  • 66
  • 224
  • 364
  • You could use an IF-statement. Something like `ON DUPLICATE KEY UPDATE field = IF(field = null, VALUES(field), field)` – Thomas Apr 15 '16 at 09:50

0 Answers0