Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: XML defined superclass constraints not validated in CR3
PostPosted: Thu Aug 06, 2009 3:37 pm 
Newbie

Joined: Thu Aug 06, 2009 3:01 pm
Posts: 5
I'm not sure if this is the correct place to post RI related issues, but I'm taking CR3 for a spin and found that constraints applied to a superclass via XML are not being validated. For example:

Code:
<constraint-mappings
        xmlns="http://jboss.org/xml/ns/javax/validation/mapping"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation=
            "http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd">
    <default-package>bv</default-package>
    <bean class="Super" ignore-annotations="false">
        <getter name="superStrValue">
        <valid/>
            <constraint annotation="javax.validation.constraints.NotNull"/>
        </getter>
    </bean>
    <bean class="Base" ignore-annotations="false">
        <getter name="strValue">
        <valid/>
            <constraint annotation="javax.validation.constraints.NotNull"/>
        </getter>
    </bean>
</constraint-mappings>


With bean classes:

Code:
package bv;
public class Base extends Super {
    private int id;       
    private String strValue;
    public void setId(int id) {
        this.id = id;
    }
    public int getId() {
        return id;
    }
    public void setStrValue(String strValue) {
        this.strValue = strValue;
    }
    public String getStrValue() {
        return strValue;
    }   
}

Code:
package bv;
//import javax.validation.constraints.NotNull;
public class Super {

    private String superStrValue;
    public void setSuperStrValue(String superStrValue) {
        this.superStrValue = superStrValue;
    }
//    @NotNull
    public String getSuperStrValue() {
        return superStrValue;
    }   
}


When validating the Base class with null strValue and superStrValue, a CV is only returned for strValue. Validating an instance of Super directly does return a CV for superStrValue, so my constraint is defined properly in XML. I do get both CV's if I specify the constraint in the superclass via annotation (as commented out in the code above).

-Jeremy


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.