Hi I have a confusing error with my Spring-boot-JPA-Hibernate classes.
I used the JPA Dali tools to create the Entity classes from my SQL Schema. While using them (with Spring-boot-jpa / hibarnate) I have some strange problems with unmatched queries. Here is one example:
Properties:
hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:mysql://localhost:3306/users
spring.datasource.username=root
spring.datasource.password=root
Entity:
@Entity
@Table(name="n_user")
@NamedQuery(name="NUser.findAll", query="SELECT n FROM NUser n")
public class NUser implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private int id;
private String imageUrl1;
private String name_first;
public NCaterer() {
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getImageUrl1() {
return this.imageUrl1;
}
public void setImageUrl1(String imageUrl1) {
this.imageUrl1 = imageUrl1;
}
public String getName_first() {
return this.name_first;
}
public void setName_first(String name_first) {
this.name_first = name_first;
}
}
Repository:
public interface UserRepo extends CrudRepository<NUser, Long> {
}
But Hibernate creates this query of it:
Hibernate:
/* select
generatedAlias0
from
NUser as generatedAlias0 */ select
nuser0_.id as id1_0_,
nuser0_.image_url1 as image_ur2_0_,
nuser0_.name_first as name_firs3_0_
from
n_user nuser0_
The Problem here is the image_url1 it should be imageurl1 as described in the Entity class. This happens on several points.
Why do Hibernate transform CamelCase getters into camel_case in the query? And how can I config it not to do it?