@Size annotation not recognized (JPA)

匆匆过客 提交于 2020-01-04 04:02:41

问题


I want to validate the length of a String before trying to insert/update the entity to the Database.

@Size(min = 1, max = 45)
@Column(name = "name", nullable = false, length = 45)
private String name;

My problem is the @Size annotation is not being recognized using NetBeans 7.3, JDK 1.6, EclipseLink (JPA 2.0).

Is there an alternative to this ?


回答1:


Try to include

<dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
    <version>1.1.0.Final</version>
</dependency>


来源:https://stackoverflow.com/questions/19566447/size-annotation-not-recognized-jpa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!