【问题标题】:Why i'm getting the error "HV000030: No validator could be found for type: java.lang.Integer."为什么我收到错误“HV000030:找不到类型的验证器:java.lang.Integer。”
【发布时间】:2016-08-25 11:57:08
【问题描述】:

我收到以下错误,

"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 资源访问外观方法时遇到此错误。 请帮助我提供所提供的详细信息。

【问题讨论】:

    标签: hibernate jpa jpa-2.0 hibernate-mapping


    【解决方案1】:

    只不过是一个疯狂的猜测; AFAIK number(9) 将始终适合 java Integer,但 number(10) 不会。

    尝试将 int 的长度降低到 9 位(或更低)位。

    【讨论】:

      猜你喜欢
      • 2017-04-21
      • 2011-08-24
      • 1970-01-01
      • 2016-04-16
      • 2013-06-09
      • 2016-06-17
      • 1970-01-01
      • 2019-03-07
      • 2021-02-04
      相关资源
      最近更新 更多