I've a problem when save an entity with assigned string Id on NHibernate...I try to explain the issue with an example.
Well, suppose to have an entity on database with ID "AAA", if I execute this statements
ENTITYTYPE entity = Session.Get<ENTITYTYPE>("AAA"); ENTITYTYPE newentity = new ENTITYTYPE() { Id = "aaa" };
Session.Delete(entity); Session.Save(newentity); Session.Flush();
On Flush NHibernate raise an exception with this message: "Could not synchronize database state with session" / "Violation of PRIMARY KEY"
It seems to have problem with Case Sensitive ID, if I use "AAA" on Id of "newentity" then it works, but in my situation is not so easy and I've to find an alternative solution.
I'm using NHibernate 2.1.2 and SQL Server 2005
How can avoid this exception? Can you help me?
|