1
I am making an application with Hibernate, but is generating and error:
"ids for this class must be Manually Assigned before Calling save()"
The class that’s saying you’re wrong is like this..
@Entity
@Table(name = "USER")
public class TodoModel {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id_todo;
private String nomeTodo;
private String usuario;
...Getters/Setters/HashCode/Equals..
And the table was created this way
CREATE TABLE USER (
id_todo INT(5) NOT NULL AUTO_INCREMENT,
nomeTodo VARCHAR(15),
usuario VARCHAR(15),
PRIMARY KEY (id_todo)
);
Even switching the Generationtype method to IDENTITY did not work. The solutions I see around always suggest putting IDENTITY or AUTO that would work, but here it did not work.
What can it be?
Try adding the following annotations:
@Basic(optional = false)
 @Column(name = "id_todo",unique=true, nullable = false)
– StatelessDev
I had already seen this solution in another topic. It didn’t work either.
– Felipe Paulo