问题
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