views:

172

answers:

1

I am pretty new to both NHibernate and CSLA.NET, and I'm running into an issue where I'm essentially needing to save the same row in the database twice, within the same transaction (and therefore, session). I've read the other questions on SO w.r.t. the NonUniqueObjectException, as well as done a lot of googling, but I can't seem to make anything work.

Anyway, I create a session, begin a transaction, and do myObject = myObject.Save(). To my understanding, CSLA creates a new instance of myObject after it's been saved and returns it, which obviously is then getting assigned to myObject.

Later on (within the same transaction), I need to do myObject.Save() again. This is where the NonUniqueObjectException is occurring. I've tried locking and merging myObject with the NHibernate session, but it doesn't seem to work.

Is there something else I should be trying? Is there an easy way to do "nested" transactions with NHibernate (although I'm not sure that would solve the issue).

I'd appreciate any suggestions.

+1  A: 

why not use saveorupdate

Surya
Sorry, I guess I should have indicated the Save() method is used because myObject is a CSLA BusinessBase<T>-derived object. SaveOrUpdate does ultimately get called right at the point of persistence.
Jordan0Day