我收到以下错误,
"HV000030: No validator could be found for type: java.lang.Integer."
我的MySQL
表格如下所示,
员工
雇主
我的JPA实体位于下方,
@Entity
@Table(name = "employee")
public class Employee implements java.io.Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@JoinColumn(name = "employer_id", nullable = false)
@ManyToOne(fetch = FetchType.EAGER)
private Employer employer;
getter and setter ....
}
@Entity
@Table(name = "employer")
public class Employer implements java.io.Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@NotNull
private Integer id;
@Column(name = "city")
@Size(max = 16)
private String city;
getter and setter...
}
我的服务器日志显示错误,
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449)
at com.mycompany.server.facade.EmployeeFacade.getEmployeesByEmployer(EmployeeFacade.java:38)
我的门面课是,
line 35: public List<Employee> getEmployeesByEmployer(@NotNull Employer employer) {
line 36: return getEntityManager().createQuery("from Employee where employer.id = :employerId").
line 37: setParameter("employerId", employer.getId()).
line 38: getResultList();
line 39: }
我在尝试从Employers rest资源访问facade方法时遇到此错误。 请帮助我提供详细信息。
答案 0 :(得分:0)
只不过是狂野的猜测; AFAIK编号(9)将始终适合java Integer,但数字(10)不会。
尝试将int的长度降低到9(或更低)数字。