[
http://opensource.atlassian.com/projects/hibernate/browse/HV-43?page=com....
]
Peter Runge commented on HV-43:
-------------------------------
We are in the same situation - we are using Hibernate as the JPA provider but we also want
to run validation sometimes even though we are not persisting to the database - e.g.
business validation when user clicks on 'next' button. Duplicating nullable and
length constraints in both JPA and Hibernate validator annotations was not appealing -
another developer not aware of the situation might come in later and change one but forget
to change the other.
We got around this by writing our own implementation of AnnotationReader that translates
JPA annotations to validator annotations (e.g. @Column with nullable=false ->
@NotNull), subclass JavaReflectionManager to use our custom AnnotationReader
implementation, and use this custom reflection manager in the constructor of
ClassValidator.
Hibernate Validator could load JPA annotations for validation
-------------------------------------------------------------
Key: HV-43
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HV-43
Project: Hibernate Validator
Issue Type: Improvement
Affects Versions: 3.0.0.ga, 3.0.1
Reporter: Leonardo Pinho
Priority: Critical
Hibernate Validator could load JPA annotations fields for validation, like at @Column
(javax.persistence.Column):
public class Test {
@Column(name="NAME", length=40, nullable=false)
private String name;
}
Otherwise I have to change the code to:
public class Test {
@NotNull
@Length(max=40)
@Column(name="NAME", length=40, nullable=false)
private String name;
}
And I got a redundant code... :(
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira