NHibernate.NonUniqueObjectException in transaction (using CSLA.Net)

I'm new to both NHibernate and CSLA.NET and I am having a problem where I essentially need to save the same row to the database twice in the same transaction (and therefore session). I've read other questions about SO wrt NonUniqueObjectException as well as a lot of lookups, but I can't seem to get anything to work.

Anyway, I create a session, start a transaction and do myObject = myObject.Save (). As I understand it, CSLA creates a new instance of myObject after saving it and returns it, which obviously then gets assigned to myObject.

Later (within the same transaction) I need to execute myObject.Save () again. This is where a NonUniqueObjectException occurs. I tried to block and merge myObject with NHibernate session but it doesn't work.

Is there anything else I should try? Is there an easy way to do "nested" transactions with NHibernate (although I'm not sure if that would solve the problem).

Any suggestions would be appreciated.

+2


source to share


1 answer


why not use saveorupdate



+1


source







All Articles