Error updating database. Cause: java.sql.SQLException: Field 'book_doc_id' doesn't have a default value

created at 09-01-2021 views: 3

This error is reported because:

  1. When the id primary key is set, it is not self-incremented
  2. When adding in the background, there is no default generation to add value
  3. There is no input value in the front end and the value is passed to the back end (ID is generally not entered by the user)

So when the new method is executed, an error will be reported: the data of this field does not have a default value.


The solution is also very simple:

The best thing is to write the id generated by the field by default in the method of the back-end ServiceImp. I used the automatically generated uuid here.


In this way, the problem of error reporting is solved.

created at:09-01-2021
edited at: 09-01-2021: