-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hiberante validator fails when using collection classes
PostPosted: Tue Sep 11, 2007 4:52 am 
Newbie

Joined: Mon Nov 29, 2004 8:15 am
Posts: 8
Hi there,

It seems that Hibernate validator framework fails to validate collections when you use concrete collection classes instead of interfaces.

So, for example, if you modify the org.hibernate.validator.test.collections.Tv class to have this:

Code:
@Valid
public ArrayList<Presenter> presenters = new ArrayList<Presenter>();


instead of this:

Code:
@Valid
public List<Presenter> presenters = new ArrayList<Presenter>();


the unit test will fail.

Cheers,
Martin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 11, 2007 4:56 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
That is correct.
I am not too fussed about it, since it's a bad practice anyway but if you provide a patch to fix that, I'll apply it.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 12, 2007 5:37 am 
Newbie

Joined: Mon Nov 29, 2004 8:15 am
Posts: 8
Yes, however the following change also makes the test fail:

Code:
@Valid
private ArrayList<Presenter> presenters = new ArrayList<Presenter>();

public List<Presenter> getPresenters() {
      
   return presenters;
}


Anyways, I didn't post th entry to debate about good or bad pratices but to highlight this issue just in case it hadn't been detected and had important consequences. I haven't tested other collections though. Whatever you do with this will be your choice.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.