-->
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.  [ 1 post ] 
Author Message
 Post subject: MVC pattern for handling validation errors in NHibernate per
PostPosted: Wed Jan 26, 2011 2:30 pm 
Newbie

Joined: Mon Jun 02, 2008 9:01 am
Posts: 1
Location: Horsham, PA, USA
Environment: ASP.Net with NHIbernate2.2, with single session, started on HTTPBeginReuest.

Use Case: Post account data to Update action. Validate account and find errors, example, incorrect website url format. Need to show incorrect url on screen to user and show error message.

Actual implementation: Once the account object has been retrieved from the database via NHibernate Get, update properties from request object. Now validate the object and find some errors. Evict the account object and load the errors and account object into TempData.

Redirect from Update action to Edit action (the latter responsible for rendering the view). In the edit action I check if the TempData["account"] exists, if so, retrieve it from there since it contains all the url the user entered. Since I need to get some "child" objects from the account, need to perform a Merge of the account so the lazy loaded data can be retrieved. The show the data on the view, etc etc.

Issue: When executing the Merge on the account (from TempData["account"] get "Object is Immutable" error

Question: Is this the correct pattern for handling issues. And how can I fix the issue with getting the immutable error.

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Vert.CRM.Business" namespace="Vert.CRM.Business.Entities">
   <class name="Vert.CRM.Business.EntityInterfaces.IAccount" table="Account" dynamic-update="true">
      
      <id name="Id" column="Id" type="int" >
         <generator class="native">
         </generator>
      </id>
   <property name="Name" ><column name="Name" length="50" not-null="true" sql-type="varchar(50)" /></property>
   <property column="Website" type="string" name="Website" />

_________________
Renso Höllhumer.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.