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 

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


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:

public class A{
   B bmember1;
   B bmember2;


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

public class B{
   C cmember1;


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

public class C{
   String someString;


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

So ideally I would want the following execution sequence:

followed by
followed by
followed by
(basically member validations to run before class validations and this rule being applied recursively)

Really appreciate your help.

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.