You've added @NotNull
to the id
property. This thus means that JPA will check that this id is not null before persisting. But the id is null, since it will be generated after, by the database. So, the NotNull annotation is in direct contradiction with the fact that it's auto-generated by identity.
Simply remove the @NotNull
annotation from id
.