其中实现定义@Future的? [英] Where is implementation of @Future defined?
问题描述
Java持久和放大器;冬眠可以很容易地属性级别的约束添加到实体。
@Entity
@Table(NAME =方)
公共类PartyEntity {
@未来
公众的DateTime启动;
}
的 javax.validation.constraint.Future
注释没有一个具体的实现定义。
@Target({METHOD,FIELD,ANNOTATION_TYPE,构造函数,参数})
@Retention(运行时)
@Documented
@Constraint(validatedBy = {})
公共@interface未来{
// ...
}
在哪里实际验证实施?这怎么能扩展到允许管理员覆盖?
虽然这里没有显示,我已经使用组关于此约束的另一个目的。
由提供许多校验实现休眠,验证
:<一href=\"http://docs.jboss.org/hibernate/validator/5.0/reference/en-US/html/validator-usingvalidator.html#validator-defineconstraints-builtin\" rel=\"nofollow\">http://docs.jboss.org/hibernate/validator/5.0/reference/en-US/html/validator-usingvalidator.html#validator-defineconstraints-builtin
如果你使用Maven,只需添加以下依赖于的pom.xml
文件:
&LT;&依赖性GT;
&LT;&的groupId GT;&org.hibernate作为LT; /的groupId&GT;
&LT;&的artifactId GT;的Hibernate验证器; / artifactId的&GT;
&LT;&版GT; 5.0.0.Alpha1&LT; /版本&GT;
&LT; /依赖性&GT;
这怎么能扩展到允许管理员覆盖?
块引用>的最简单的方法是<一个href=\"http://docs.jboss.org/hibernate/validator/5.0/reference/en-US/html/validator-customconstraints.html\"相对=nofollow>写你自己的,而不是。
Java persistence & hibernate make it easy to add property-level constraints to entities.
@Entity @Table(name = "party") public class PartyEntity { @Future public DateTime start; }
The
javax.validation.constraint.Future
annotation is defined without a specific implementation.@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER }) @Retention(RUNTIME) @Documented @Constraint(validatedBy = {}) public @interface Future { // ... }
Where is actual validation implemented? How can this be extended to allow an administrator override?
Though not shown here, I am already using groups for another purpose on this constraint.
解决方案Implementations for many validators supplied by
hibernate-validator
: http://docs.jboss.org/hibernate/validator/5.0/reference/en-US/html/validator-usingvalidator.html#validator-defineconstraints-builtinIf you are using Maven just add following dependency to
pom.xml
file:<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>5.0.0.Alpha1</version> </dependency>
How can this be extended to allow an administrator override?
The simplest way is to write your own instead.
这篇关于其中实现定义@Future的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!