-->
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: Conditionnaly disable hibernate validation ?
PostPosted: Tue Sep 14, 2010 6:18 am 
Newbie

Joined: Tue Sep 14, 2010 6:11 am
Posts: 2
Hi,

I have to apply validation on a bean (I invoke manually the validator on the web tier, and let persistence stack invoke it automatically), but, on a special case, where my Bean has a property "status" with the value "draft", I don't want valdiation to occur.
In web tier, it's quite easy by using Groups and invoking the Validator with the correct group depending on that property ; but I didn't found the correct way to solve the problem on the persistence stack ?

How can I solve my problem ? :)

Thanks in advance for your answers,

mf.


Top
 Profile  
 
 Post subject: Re: Conditionnaly disable hibernate validation ?
PostPosted: Fri Sep 17, 2010 9:18 am 
Hibernate Team
Hibernate Team

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

you also do it via groups. Check the "Hibernate event-based validation" section in the Validator online documentation. Goes somewhat like this:

Quote:
Whenever a PreInsertEvent, PreUpdateEvent or PreDeleteEvent occurs, the listener will verify all constraints of the entity instance and throw an exception if any constraint is violated. Per default objects will be checked before any inserts or updates are made by Hibernate. Pre deletion events will per default not trigger a validation. You can configure the groups to be validated per event type using the properties javax.persistence.validation.group.pre-persist, javax.persistence.validation.group.pre-update and javax.persistence.validation.group.pre-remove. The values of these properties are the comma-separated, fully specified class names of the groups to validate.


So you just have to configure the the properties javax.persistence.validation.group.*

--Hardy


Top
 Profile  
 
 Post subject: Re: Conditionnaly disable hibernate validation ?
PostPosted: Fri Sep 17, 2010 10:15 am 
Newbie

Joined: Tue Sep 14, 2010 6:11 am
Posts: 2
Totally right.

Again : rtfm...

Thank you for your answer ! :)


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