javax.servlet.ServletException:HV000030:找不到类型验证器:java.lang.Integer [英] javax.servlet.ServletException: HV000030: No validator could be found for type: java.lang.Integer

查看:35
本文介绍了javax.servlet.ServletException:HV000030:找不到类型验证器:java.lang.Integer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须更新我数据库中的信息.

I have to update information in my database.

FacadePatient.java 类代码:

public Patient update(Patient p) {

    Patient pat = em.find(Patient.class, p.getPatientId());
    p.setPatientPhone(pat.getPatientPhone());
    p.setPatientDateNaiss(pat.getPatientDateNaiss());
    p.setPatientEmail(pat.getPatientEmail());
    p.setPatientJob(pat.getPatientJob());
    p.setPatientSmoking(pat.getPatientSmoking());
    p.setPatientSize(pat.getPatientSize());
    em.merge(pat);
    return p;
}

推荐答案

HV000030:找不到类型验证器:java.lang.Integer

当你在 Hibernate Validator 风格中使用 JSR303 bean 验证并且你在你的 JPA 实体中有 Hibernate 特定的 @NotEmpty 像这样的 Integer 属性时会发生这种情况:

That will happen when you use JSR303 bean validation in flavor of Hibernate Validator and you have in your JPA entity the Hibernate-specific @NotEmpty on an Integer property like this:

@NotEmpty
private Integer some;

这是完全错误的.整数不能被视为 字符串、集合、映射或数组.改用标准的 @NotNull.

This is completely wrong. An integer cannot be considered as a string, collection, map or array. Use the standard @NotNull instead.

@NotNull
private Integer some;

请注意,具体问题与 JSF 完全无关.将来,请学习如何尽可能排除噪音并确定具体问题,例如单独执行 JPA 代码.JSF 只是这里的 HTTP/MVC 信使,而 PrimeFaces 只是 HTML/CSS/jQuery/UI 代码生成器.

Please note that the concrete problem is completely unrelated to JSF. In the future, please learn how to exclude as much as possible noise and naildown the concrete problem by e.g. executing the JPA code individually. JSF is merely the HTTP/MVC messenger here and PrimeFaces is merely the HTML/CSS/jQuery/UI code generator.

这篇关于javax.servlet.ServletException:HV000030:找不到类型验证器:java.lang.Integer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆