我有一个具有以下属性的 JPA 实体:
public class Person implements Serializabe {
...
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 45)
@Column(name = "name", nullable = false, length = 45)
private String name;
...
它的观点:
<h:outputLabel value="Name: "/>
<h:inputText id="name"
value="#{personBean.person.name}"
validator="#{personValidator.validate}"/>
<rich:message for="name"/>
检查 0 < name.length personValidator
< 45 是否已存在于数据库中;它工作正常。当我尝试添加一个空名称或大于 45 个字符时,我得到了正确的验证器消息,但在 Glassfish 输出中显示:
INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=contentForm:name[severity=(ERROR 2), summary=(size must be between 1 and 45), detail=(size must be between 1 and 45)]
我尝试添加<validation-mode>NONE</validation-mode>
到我的 persistence.xml 但没有效果。如何避免此@Size
注释验证?