-->
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: Check validity before persisting
PostPosted: Fri Jan 20, 2006 7:07 am 
Newbie

Joined: Mon Jan 16, 2006 5:37 am
Posts: 1
All my business objects have an IsValid property to check on mandatory fields etc. Before saving these objects to the database I want all objects to be valid. But when calling the Flush method of the session, obviously this IsValid property is ignored. How can I assure that NHibernate is only persisting valid objects?

Current NH version is 1.0.2


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 9:22 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Either create an interceptor (a special class implementing IInterceptor) and do the check in its methods, or make your objects implement IValidatable, then their Validate method will be called when they are being persistent.

The second solution is a bit more intrusive than the first and is not recommended.


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.