-->
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: Validation on cascaded updates of collection members
PostPosted: Fri Aug 05, 2005 3:09 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
I've got a parent object that has a collection of child objects and I need to ensure a business rule for validation is run before child objects are persisted. I've got a cascade set up so that the child objects are automatically updated when the parent object is saved.

Is there a way to intercept the update of each child before it's saved in this scenario? I've looked into the ILifecycle OnUpdate, but it doesn't seem get called, and the documentation says that IValidatable is unpredictably called.

And IInterceptor doesn't seem to be quite right either because I'd need to move my validation code out to another object and because only one IInterceptor can be associated with a session I'd need to mix the validation code for all domain objects together in one class (have I understood this right?)

I'm getting a bit desparate here - can anyone enlighten me?

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 05, 2005 11:52 pm 
Senior
Senior

Joined: Sat Sep 10, 2005 3:46 pm
Posts: 178
Has there been a solution for this? I am new to using NHibernate and need to perform a data validation check before an persistent object is updated.

It seems that the OnUpdate method of ILifeCycle is the perfect place for this. The fact that OnUpdate does not get called when flush is called is a little disturbing though.

Is there a better pattern for preventing updates when data is invalid? What are others doing?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 06, 2005 1:55 am 
Senior
Senior

Joined: Sat Sep 10, 2005 3:46 pm
Posts: 178
It seems that IValidatable may be the route for me to go to validate the object before it is persisted. Does anyone know if Validate method is called before any persistence operation? The documentation states that it might be called at unpredicateble times. Can I at least guarantee that it will be called?


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