habuma / spring-in-action-5-samples

Home for example code from Spring in Action 5.
Apache License 2.0
1.21k stars 1.04k forks source link

chapter 3: could not execute statement [NULL not allowed for column "CREATEDAT"; SQL statement: insert into taco (created_at,name,id) #130

Closed tomwang57 closed 6 months ago

tomwang57 commented 6 months ago

When saving a taco, error:

could not execute statement [NULL not allowed for column "CREATEDAT"; SQL statement:
insert into taco (created_at,name,id) values (?,?,?) [23502-224]] 
[insert into taco (created_at,name,id) values (?,?,?)]; 
SQL [insert into taco (created_at,name,id) values (?,?,?)]; constraint [null]] with root cause

It seems like the @PrePersistent in Taco.java does not work:

  @PrePersist
  void createdAt() {
    this.createdAt = new Date();
  }