-->
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: Validator -- trying to hide validation details/annotations.
PostPosted: Wed Dec 16, 2009 12:30 pm 
Newbie

Joined: Tue Aug 09, 2005 8:06 pm
Posts: 6
So, I'm fairly familiar with JSR-303 and have used GWT-Validations. I'm now looking into using the latest Hibernate Validator...

I have these very dumb DTO's, that I eventually want to validate.

Is there an idiom for hiding the annotation based validation of said DTO's from a client user? We're not trying to be secret, we're just trying not to confuse novice (or novice to Java)users, and we plan to document most validation at the API/Java doc level.

Would it be possible to define the DTO without annotations, then define a ValidatableDTO subclass that exists only on the app tier(and would be easy to copy values from the regularDTO and the Validatable one), and put the annotations on the getters(thus overriding the getter with the exact same implementation)?

Note that I prefer not to use the XML validation descriptors.

I figure either:
a) I'm trying to do something that the current design doesn't support.
b) What I'm proposing(overriding getters) won't work or is too kludgy for any self respecting Java developer to advocate.
c) There is a much easier way to do what I want to do... lol

Anyone have any suggestions?


Top
 Profile  
 
 Post subject: Re: Validator -- trying to hide validation details/annotations.
PostPosted: Wed Dec 16, 2009 2:28 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

what's new about annotations? They are a language feature since 1.5. I don't think you confuse any Java developer with Annotations? Are you trying to avoid generics as well?
Personally I think it does not hurt to have validation annotation in your code. What better documentation can you have than the actual validation constraints? And is your "client" actually working with your actual source code? Only then would be annotations be visible.

But if you really only want validation in the app tier XML is the way to go. Adding additional ValidationXYZ classes adds more confusion than anything. What's wrong with XML in this case?

--Hardy


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.