-->
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.  [ 2 posts ] 
Author Message
 Post subject: Class validators not being called on embedded @Valid objects
PostPosted: Fri Jun 01, 2012 11:53 am 
Newbie

Joined: Sun Aug 28, 2005 1:29 pm
Posts: 12
I have a class that looks like this:

Code:
public class A {

    @Valid
    @Embedded
    Z z = new Z();

}

@Embeddable
public class Z {

    @NotNull
    String name;

    @AssertTrue
    public boolean validateMe() {
        return false;
    }

}

A a = new A();
// get the validator
validator.validate(a);



Z.name gets validated, but the validateMe() method is never called. Shouldn't it be?


Top
 Profile  
 
 Post subject: Re: Class validators not being called on embedded @Valid objects
PostPosted: Fri Jun 01, 2012 3:25 pm 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Bean Validation itself doesn't invoke any methods besides JavaBeans getter methods (in case of property-level constraints). So if you put the @AssertTrue constraint to a getter method such as isValid(), this method would be invoked.

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


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

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.