注解 | 应用目标 | 运行时检查 | Hibernate元数据效果 |
---|
@Length(min=, max=) | property (String) | check if the string length match the range | Column length will be set to max |
@Length(min=, max=) | property (String) | 检查字符串长度是否符合范围 | 列长度会被设到最大值 |
@Max(value=) | property (numeric or string representation of a numeric) | check if the value is less than or equals to max | Add a check constraint on the column |
@Max(value=) | property (numeric or string representation of a numeric) | 检查值是否小于或等于最大值 | 对列增加一个检查约束 |
@Min(value=) | property (numeric or string representation of a numeric) | check if the value is more than or equals to min | Add a check constraint on the column |
@Min(value=) | property (numeric or string representation of a numeric) | 检查值是否大于或等于最小值 | 对列增加一个检查约束 |
@NotNull | property | check if the value is not null | Column(s) are not null |
@NotNull | property | 检查值是否非空(not null) | 列不为空 |
@Past | property (date or calendar) | check if the date is in the past | Add a check constraint on the column |
@Past | property (date or calendar) | 检查日期是否是过去时 | 对列增加一个检查约束 |
@Future | property (date or calendar) | check if the date is in the future | none |
@Future | property (date or calendar) | 检查日期是否是将来时 | none |
@Pattern(regex="regexp", flag=) | property (string) | check if the property match the regular expression given a match flag (see java.util.regex.Pattern ) | none |
@Pattern(regex="regexp", flag=) | property (string) | 检查属性是否与给定匹配标志的正则表达式相匹配(见 java.util.regex.Pattern ) | none |
@Range(min=, max=) | property (numeric or string representation of a numeric) | check if the value is between min and max (included) | Add a check constraint on the column |
@Range(min=, max=) | property (numeric or string representation of a numeric) | 检查值是否在最小和最大值之间(包括临界值) | 对列增加一个检查约束 |
@Size(min=, max=) | property (array, collection, map) | check if the element size is between min and max(included) | none |
@Size(min=, max=) | property (array, collection, map) | 检查元素大小是否在最小和最大值之间(包括临界值) | none |
@AssertFalse | property | check that the method evaluates to false (useful forconstraints expressed in code rather than annotations) | none |
@AssertFalse | property | 检查方法的演算结果是否为false(对以代码方式而不是注解表示的约束很有用) | none |
@AssertTrue | property | check that the method evaluates to true (useful for constraints expressed in code rather than annotations) | none |
@AssertTrue | property | 检查方法的演算结果是否为true(对以代码方式而不是注解表示的约束很有用) | none |
@Valid | property (object) | Perform validation recursively on the associatedobject | none |
@Valid | property (object) | 对关联对象递归的进行验证 | none |