Jordan0Day
Jordan0Day

Reputation: 1416

NHibernate.NonUniqueObjectException within a transaction (using CSLA.Net)

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.

Upvotes: 2

Views: 503

Answers (1)

Surya
Surya

Reputation: 4992

why not use saveorupdate

Upvotes: 1

Related Questions