Here is the problem
@Entity
public class User {
@Id
String user_Id;
}
You have declared user_Id to be the primary key of the table. Therefore it is must not be null. I am sure that in your controller you pass the object User without providing a key. In many cases we leave the database to create a primary key, but in your case it does not work that way. So you must provide a user_Id
for your User before calling .save()
That is the reason for the error that you get
{" ids for this class must be manually assigned before calling save()"}
If you wish to get automatically a value for your key, either from JPA or from your database you must provide another anonnotation the @GeneratedValue and select an option.
But for that to work you must change your id field from String to Long or Integer.
Here is an example of how that could work
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
}
GenerationType. has many other options.