Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Cascade bean validation for associated classes
PostPosted: Wed Apr 15, 2015 1:24 pm 
Newbie

Joined: Wed Apr 15, 2015 1:21 pm
Posts: 1
I was referring to:

http://stackoverflow.com/questions/10380209/java-bean-validation-groupsequence-with-class-level-constraint

This works fine for simple classes. But I am working on something as follows:

Class A (validated by AValidator) has a member Class B (validated by BValidator)

has a member Class C(validated by Cvalidator) as well as some primitive members like Strings.

Ideally I would like the string members of Class C to be validated first followed by CValidator followed by BValidator followed by AValidator.

Note: All the classes follow association, they do not have a parent child relationship.

Here is how the code looks like:

Code:
@AType
public class A{
   B bmember1;
   B bmember2;

}

@Constraint(validatedBy = AValidator.class)
public @interface AType{
//some code
}

@BType
public class B{
   C cmember1;

}

@Constraint(validatedBy = BValidator.class)
public @interface BType{
//some code
}

@CType
public class C{
   @strvalid
   String someString;

}

@Constraint(validatedBy = CValidator.class)
public @interface CType{
//some code
}

So ideally I would want the following execution sequence:

Code:
strValid
followed by
Code:
Cvalidator
followed by
Code:
BValidator
followed by
Code:
AValidator
(basically member validations to run before class validations and this rule being applied recursively)

Really appreciate your help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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.