-->
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.  [ 6 posts ] 
Author Message
 Post subject: Any nice way to catch & display InvalidValue??
PostPosted: Tue Aug 14, 2007 7:32 am 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
Hi,

from what I've read, I can't figure anything better than adding a log.error(validationMessages[i]) in each of the creating/modifying methods.

OK, there's not much of them at the lowest DAO level, but still it'd be nice to have a declarative way to trigger the validation messages display.

An aspect could probably do, but it'd be better if included with the validation package itself.
Is there anything coming concerning the issue?

cheers,

_________________
/nodje


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 12:42 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You mean displaying the message to the user in a UI? Seam does that through a JSF tag, it smartly replace the validators of JSF and put messages through the Faces messages.
What do you have in mind exactly?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 10:51 pm 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
no I just mean for the developers to have a way of understanding what is going on.
Because it's a hell of a job to determine where the validation error comes from on big objects and it's also quite not nice to add code to all methods for them to display explicit validation error messages.

I just wish could write the code to display the validationMessages in a single method, and not to have to add anything to the try catch of my create/update DAO methods. This is what I meant by declaratively.

I think that should belong to the HibernateValidation package itself. I'm thinking of something like an annotation -- @DisplayValidationError or even better a config in a XML file with pointcut like syntax. (Display error messages in logs for all DAO level methods which name starts with create* or update*)

_________________
/nodje


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 28, 2007 3:03 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Traditionally that's the job of the upper most layer to handle and display the exception accordingly.
If using a servlet, you could have a filter that display the exception with the full details (ie having the knowledge of the Validator exception).

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 28, 2007 9:52 pm 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
In my case I don't use Hibernate validator to handle upper level validation. The latter is implemented elsewhere.

I find it useful as a way to enforce my entities well-formedness, to avoid database exception and to document some constraint that would previously only be implemented in the database layer.
I don't use Seam, I don't use JSF, I can't use Validator as a upper layer validation.

It's kind of last resort validation for uncatched mistakes at development time and to track errors on server side created object (those that don't go through upper layer validation).

My app users should never Validator exception, only developers.

That's maybe not what you envision for you lib usage :-)
But that's the way I use it, and I actually find it pretty convenient.

_________________
/nodje


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 30, 2007 5:06 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Let me rephrase, you can implement this exception and log handling in the upper most layer in your system: this layer can be your server side boundaries or your UI, this is not relevant.

And you're correct, I think that's not the job of a library.

_________________
Emmanuel


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