-->
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: searching simple (!) step-by-step guide for using validator
PostPosted: Fri Oct 10, 2008 2:42 pm 
Beginner
Beginner

Joined: Wed Oct 08, 2008 10:59 am
Posts: 37
Assume I want to add some logical constraints to certain fields.
For example the value of field20 must be between 210 and 220
or the maxlength of string variable stringABC must be lower than 20
how can I achieve this with Hibernate?

I heard that I can use the built-in validator.
But how does that work?

I am not searching for a comprehensive reference guide
but a simple example or step-by-step guide.
Something like a "Hello world" for applying the validator for say the both constraints mentioned above.

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 12, 2008 2:42 pm 
Hibernate Team
Hibernate Team

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

I think you should look at Hibernate Validator. Constraints are defined by annotations like in the example on the online doc - http://www.hibernate.org/hib_docs/validator/reference/en/html_single/#d0e319. Get the latest release, add the jars to your classpath, annotate your domain model with constraints and call ClassValidator. As easy as that.

There is also soon a reference implementation of JSR 303 available which will replace Hibernate Validator. However, we are planning to offer some sort of transparent bridging for people using Hibernate Validator.

--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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.