-->
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: Question about Hibernate Validator
PostPosted: Thu Nov 19, 2009 6:56 am 
Newbie

Joined: Thu Nov 19, 2009 6:34 am
Posts: 1
Hi,

I am trying to validate data from classes which are in inheritance relation.
For example i have these two classes:

class Apple {
...
private String color;
....
//get , set
}

and than:

class MyApple extends Apple {
...
}

I am trying to validate the "color" of the apple in MyApple class without to create a instance of Apple class.
Something like MyApple a=new MyApple(..,"green",..);

Right now my constraints xml file have something like:

<bean class="test.Apple" ignore-annotations="false">
<getter name="Color">
<constraint annotation="javax.validation.constraints.Size">
<element name="min">1</element>
<element name="max">20</element>
</constraint>
</getter>
...
</bean>

and:
<bean class="test.MyApple" ignore-annotations="false">
...
<!-- no validation for color -->
</bean>

Problem is that trying in this way the validation is not working... for "MyApple" , i am missing some annotations in xml constraints file ? (something to tell which class inherits from which) , is it possible to handle this inheritance in this way ?

Please if you have an idea or a sugestion give me an hand !

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.