Hibernate version: 3.3.0
With the Hibernate Validator (release version 3.3.0 GA I believe) is it possible to put an Annotation for an entity collection.. Basically, I want to be able to type an annotation for each elements of a collection on the one-to-many relation...
Ex :
public class Owner {
@OneToMany(mappedBy="owner",cascade={CascadeType.ALL})
@AnnotationToValideCollections(Pet.property="NotNull",
messsage="Pet.property is invalids")
private Set<Pet> pets;
}
Where "@AnnotationToValideCollections" would validates each Pet elements of my collections with some conditions on the Pet property
and return message errors with simply calling the Hibernate Validator class :
ClassValidator addressValidator = new ClassValidator(Owner.class, ResourceBundle.getBundle("messages", Locale.ENGLISH) ;
The problem I am having is that if some property of Pet may be null and
I do want to iterates the collections "pets" to check the property of Pet is NOT NULL for some particular case...
I do not believe there is a way to do it, but if someone may inform me if it's something possible or if it's new annotation for collection that will be release in next hibernate version.... I ahve a workaround in my project by iterates the collections in my controller but it's not clean...
Thanks!
|