sunmingtao / sample-code

3 stars 4 forks source link

Grails hibernate: field with null value cannot be persisted? #254

Open sunmingtao opened 3 years ago

sunmingtao commented 3 years ago

The column in the table is nullable.

The code below fails to persist the update.

TroveApi api = TroveApi.findByUserId(userId)
api.setQuota(apiQuota)
api.setDeactivatedReason(null)
api.setDateDeactivated(null)
api.save(flush: true)
sunmingtao commented 3 years ago

It works when I replace null with empty string.

api.setDeactivatedReason("")
api.setDateDeactivated("")