79413482

Date: 2025-02-05 02:05:37
Score: 0.5
Natty:
Report link

When you call PUT api, you only pass name in the body, but the request User type, so Spring will understand that your body is:

{
  "id": null,
  "name": "your_input_name",
  "date_created": null
}

And in your update method, you only copy object with id => the dateCreated still null. That why when it save to db, the date_created column is null

You can first query the object in db with id, change name field then save it back.

Or you can add updatable = false to make sure date_created will not be updated.

@Column(name= "date_created", updatable = false)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): When you
  • Low reputation (1):
Posted by: Kezlo