-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate Validator for collections
PostPosted: Sat Feb 07, 2009 10:14 am 
Newbie

Joined: Sun Feb 01, 2009 12:15 pm
Posts: 3
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.