I've been trying to create a new Student field that could be added into my MySQL database.
I'm using Spring Boot, MySQL Workbench and from my understanding everything is just as it should be - yet - it's still not working correctly.
This is how my Student class look like:
@Entity
@Table(name = "studenttab")
public class Student {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "sname")
private String name;
@Column(name = "scourse")
private String course;
@Column(name = "sfee")
private Double fee;
And this is how my test method looks like:
@Test
void testCreateStudent() {
Student student = new Student();
student.setName("Łukasz");
student.setCourse("WoW-Best-Gold-Guide");
student.setFee(100.00);
studentRepository.save(student);
}
StudentRepository is just extending a CrudRepository.
It seems like Hibernate is not able to create Ids automatically, which should be done by @GeneratedValue annotation. Not sure what's wrong and what I can do to repair it.
¯_( ツ )_/¯