[英]Spring boot with Spring data JPA: could not extract ResultSet
我用Spring数据开发一个Spring启动应用程序JPA是否有人有这个问题的解决方案?:我的bean:
@Entity
@Table(name = "employee", catalog = "explorerrh")
public class Employee implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Integer idemployee;
private String employeeName;
private String employeeLastName;
private String employeeCin;
private String employeePhone;
private String employeeAdress;
private String employeePost;
private String employeeCnss;
private String employeeCv;
private String employeePhoto;
private String employeeSalaire;
public Employee() {
}
public Employee(String employeeName, String employeeLastName,
String employeeCin, String employeePhone, String employeeAdress,
String employeePost, String employeeCnss, String employeeCv,
String employeePhoto, String employeeSalaire) {
this.employeeName = employeeName;
this.employeeLastName = employeeLastName;
this.employeeCin = employeeCin;
this.employeePhone = employeePhone;
this.employeeAdress = employeeAdress;
this.employeePost = employeePost;
this.employeeCnss = employeeCnss;
this.employeeCv = employeeCv;
this.employeePhoto = employeePhoto;
this.employeeSalaire = employeeSalaire;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "idemployee", unique = true, nullable = false)
public Integer getIdemployee() {
return this.idemployee;
}
public void setIdemployee(Integer idemployee) {
this.idemployee = idemployee;
}
@Column(name = "employeeName", length = 45)
public String getEmployeeName() {
return this.employeeName;
}
public void setEmployeeName(String employeeName) {
this.employeeName = employeeName;
}
@Column(name = "employeeLastName", length = 45)
public String getEmployeeLastName() {
return this.employeeLastName;
}
public void setEmployeeLastName(String employeeLastName) {
this.employeeLastName = employeeLastName;
}
@Column(name = "employeeCIN", length = 45)
public String getEmployeeCin() {
return this.employeeCin;
}
public void setEmployeeCin(String employeeCin) {
this.employeeCin = employeeCin;
}
@Column(name = "employeePhone", length = 45)
public String getEmployeePhone() {
return this.employeePhone;
}
public void setEmployeePhone(String employeePhone) {
this.employeePhone = employeePhone;
}
@Column(name = "employeeAdress", length = 45)
public String getEmployeeAdress() {
return this.employeeAdress;
}
public void setEmployeeAdress(String employeeAdress) {
this.employeeAdress = employeeAdress;
}
@Column(name = "employeePost", length = 45)
public String getEmployeePost() {
return this.employeePost;
}
public void setEmployeePost(String employeePost) {
this.employeePost = employeePost;
}
@Column(name = "employeeCNSS", length = 45)
public String getEmployeeCnss() {
return this.employeeCnss;
}
public void setEmployeeCnss(String employeeCnss) {
this.employeeCnss = employeeCnss;
}
@Column(name = "employeeCV", length = 45)
public String getEmployeeCv() {
return this.employeeCv;
}
public void setEmployeeCv(String employeeCv) {
this.employeeCv = employeeCv;
}
@Column(name = "employeePhoto", length = 45)
public String getEmployeePhoto() {
return this.employeePhoto;
}
public void setEmployeePhoto(String employeePhoto) {
this.employeePhoto = employeePhoto;
}
@Column(name = "employeeSalaire", length = 45)
public String getEmployeeSalaire() {
return this.employeeSalaire;
}
public void setEmployeeSalaire(String employeeSalaire) {
this.employeeSalaire = employeeSalaire;
}
}
我的服务是这样的:
interface EmployeeRepository extends Repository<Employee, Long> {
Page<Employee> findAll(Pageable pageable);
Employee findByEmployeeNameAndEmployeeCin(String employeeName, String cin);
}
然后我在com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'employee0_.employee_adress' in 'field list'
上收到此错误com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'employee0_.employee_adress' in 'field list'
我的数据库是正确生成的,它对bean的生成是正确的! 我真的不明白这是什么问题! 所以请有人帮我解决这个问题吗? 谢谢你们,如果你需要任何其他信息,请问我
正如另一个答案所指出:
默认情况下,Spring使用
org.springframework.boot.orm.jpa.SpringNamingStrategy
来生成表名。 这是org.hibernate.cfg.ImprovedNamingStrategy
一个非常细的扩展。 该类中的tableName方法传递一个源String值,但如果它来自@Column.name
属性,或者它是从字段名称隐式生成的,则它不知道。ImprovedNamingStrategy将CamelCase转换为SNAKE_CASE,因为EJB3NamingStrategy只使用表名不变。
如果您不想更改命名策略,则始终只需以小写字母指定列名:
@Column(name="testname")
另外,您确定该列是“employeeadress”而不是“employeeaddress”吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.