-->
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: [Validator] Polymorphism and child validators
PostPosted: Mon Nov 19, 2007 10:53 am 
Newbie

Joined: Mon Nov 19, 2007 9:01 am
Posts: 8
Hibernate version:
3.2.4 with Validator 3.0.0.GA

R7943 added the ability to handle @Valid annotations on fields that are declared as a superclass of the actual value.

In theory, the classValidator for the field annotated @Valid should be in the childClassValidators collection. However, this collection is keyed on the declared class of the field - if the actual field value has a different class the validator will not be found. For this purpose a subclass counts as "different".

R9743 handles this by simply creating a new classValidator if the expected childClassValidator is not found.

However, unlike a normal child validator, the new validator created in this case is created using the minimal constructor and does not get passed any of the parent's state - in particular, the message bundle and the message interpolator. I'd love to know if there's a reason for this omission.

Assuming there isn't, I can think of three ways to go.

1. Just use the full constructor, like createChildClassValidator does
2. Actually call createChildClassValidator (not sure of the mechanics of creating an XMember instance)
3. Make the childClassValidators collection lookup aware of class hierarchy

I've checked in Jira and I can't see any issues that look like this.

Jaime Metcher


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.