Henrique Ordine Henrique Ordine - 4 months ago 53
MySQL Question

Spring Data doesn't seem to understand @Column name

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,

, annotated with
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
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
annotation for the field, so I thought it was some default Hibernate behaviour to map firstName to first_name, but I've added the
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:

public class Respondent {

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;


By default Spring uses jpa.SpringNamingStrategy to generate the table names.

The ImprovedNamingStrategy will convert CamelCase to SNAKE_CASE where as the EJB3NamingStrategy just uses the table name unchanged.

You can try to change the naming_strategy to:


or the @Column name attribute should be in lowercase @Column(name = "firstname")

For Hibernate 5 this should work (I am not quite sure if you also need the above one. But try it with both):