I'm using Spring-boot 1.4.1.RELEASE, with Spring Data and Hibernate to persist some data into a MySQL database.
I have this class, Respondent
, annotated with @Entity
and one of the fields annotated as below:
@Column(name = "firstName", nullable = false, length = 100)
private String firstName;
When I try to save a Respondent to the DB by calling save()
on its CrudRepository<Respondent, Long>
, I get this error:
ERRORcom.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'first_name' in 'field list'
This error had started occurring before I had the @Column
annotation for the field, so I thought it was some default Hibernate behaviour to map firstName to first_name, but I've added the @Column
annotation to it and nothing changed. Is it still wrong? I've already rebuilt the application with mvn clean package
.
Here's my Respondent entity:
@Entity
public class Respondent {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@Column(name = "firstName", nullable = false, length = 100)
private String firstName;
private String tussenvoegsel;
@Column(name = "lastName", nullable = false, length = 100)
private String lastName;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "Company_id", nullable = false)
private Company company;