-->
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.  [ 5 posts ] 
Author Message
 Post subject: Using Validation Application Block with NHibernate
PostPosted: Fri May 25, 2007 7:09 am 
Beginner
Beginner

Joined: Wed Nov 29, 2006 12:23 pm
Posts: 42
I am working on a system that has been architected using the suggested model in Billy McCafferty's article on codeproject

http://www.codeproject.com/aspnet/NHibe ... ctices.asp

and am trying to integrate this with the use of the Microsoft Validation Application Block (VAB) found in the latest version of the Enterprise Library.

I had implemented this such that when my IInterceptor implementation called OnSave or OnFlushDirty, the associated entity was validated. At the end of all validation, if any object failed validation an exception was thrown with the collection of validation messages.

What I then found was that because I'm using the session-per-request model, Flush would usually be called in the EndRequest event on the HttpModule. As a result, the exception would be thrown, but thrown after all soap processing had taken place, and therefore outside of the boundary within which anything useful could be done with it. Instead of catching a relevant exception on the front end, an error relating to incorrect response type would be displayed.

The other option I looked into was to call validate on the entity in the call to SaveOrUpdate, but it is necessary to validate the entire entity hierarchy, not just the entity. Therefore using [ObjectValidator] would allow the validation to propagate to associated entities, but this does not respect lazy loading, and a mass of data would be loaded from the database to be validated.

I realise there are flaws in both of these approaches, but am trying to find an approach that will work.

I am trying to achieve a validation implementation where the validation can all be localized to the entity being validated, that is called automatically so that the developer doesn't have to call Validate() in his code, and that will allow for the collection and reporting of all validation errors (rather than one by one).

Has anyone successfully integrated the VAB with NHibernate and if so how?


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 26, 2007 11:58 am 
Beginner
Beginner

Joined: Wed Nov 29, 2006 12:23 pm
Posts: 42
anyone? any tips?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 29, 2007 2:14 am 
Newbie

Joined: Thu Apr 26, 2007 4:07 am
Posts: 7
Location: Ukraine
Are you implemented the IValidatable interface (4.5 in the reference documentation)?
You can also validate your business object using validation concept from the CSLA Framework (http://www.lhotka.net/Area.aspx?id=4)

_________________
Stanislaw Tristan


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 29, 2007 4:17 am 
Beginner
Beginner

Joined: Wed Nov 29, 2006 12:23 pm
Posts: 42
s_tristan wrote:
Are you implemented the IValidatable interface (4.5 in the reference documentation)?


No I'm not implementing IValidatable, as it was deprecated in 1.2, along with ILifecycle.


s_tristan wrote:
You can also validate your business object using validation concept from the CSLA Framework (http://www.lhotka.net/Area.aspx?id=4)


Thanks - will have a look into this.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 29, 2007 8:25 am 
Newbie

Joined: Thu May 03, 2007 2:30 am
Posts: 18
hitch wrote:
s_tristan wrote:
Are you implemented the IValidatable interface (4.5 in the reference documentation)?


No I'm not implementing IValidatable, as it was deprecated in 1.2, along with ILifecycle.


s_tristan wrote:
You can also validate your business object using validation concept from the CSLA Framework (http://www.lhotka.net/Area.aspx?id=4)


Thanks - will have a look into this.


There is a recent show on DNRTV showing you how to integrate CSLA with "other" Data Access tecnology. They are using "DTOs" to move the Data from their business object to the persistance layer. The real Validation would only take place in the business objects, and it would determine if the object gets passed to the persistance layer or not... (But this Validation logic is also available on the client, so you can avoid saving an invalid object anyway)

Also all your objects must inherit from a set of certain base classes, in order to gain most of their functions (Undo/Redo, Dirty Tracking, Business Rules etc...)

Also note, that the most current non-beta Version (2.1) has some heavy redesign on the broken rules collections. They now also implement a warning and information level, and now support short circuting...


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