Ok, some more thoughts here, so when I forced a call to Flush after
the SaveOrUpdate method, I noticed the behavior was still the same
that during the EndRequest handler I was still trying to save this
object. So what I am assuming is that when nHibernate encounters an
error while trying to save an object that it doesn't remove the object
from its list of dirty objects. So when my handler executes (Which
calls Flush and then Close()), nHibernate tries to save this object
again, but encounters the same error, resulting in an unhandled
exception.
Just to verify I removed all the calls to Flush & Close to see if the
object would be saved when calling SaveOrUpdate() and I noticed it was
not. My object was originally loaded up as property on another object
(many-one relationship), it's mapped as follows:
<class name="xxx.User" table="[User]" lazy="false">
<many-to-one name="Organization" class="xxx.Organization" not-
null="false" insert="true" update="true" cascade="save-update"
fetch="join" >
<column name="OrganizationId"/>
</many-to-one>
</class>
When I call the SaveOrUpdate method, I am passing the Organization
object not the user object.
This has raised a second question, do people usually flush when
closing the session in the open session in view pattern and if so how
do you handle reporting to the user in a graceful manner that an error
occured.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---