Search code examples
jqueryspring-bootthymeleaf

need help to fix spring boot project


I'm trying to add new name,lastName and email. After clicking save button I got an error message " Field error in object 'employee' on field 'id' " How can I fix this error . I'm using spring boot with thymeleaf and jquery.

enter image description here

And

enter image description here

project link is : Here

thank you


Solution

  • Declare your column id as Integer and dont pass it from UI or pass value as null object. If you want to keep it int then always pass 0 from UI. Passing empty String will always raise exception until you dont have your own messageConverter handling.

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name=id)
    private Integer id;