Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Hi, i need some help with one strange problem... The application that I'm currently building inserts a row in a updateInfo table when ever a domain object is changed. All instances of the program scan for updates and whenever a new update is registered the domain objects that were changed are Refreshed. That's how I keep the object up to date.
This is part of the update routine:
foreach (Object[] obj in temp)...
objecttoRefresh = session.Get(Type.GetType(temp_objecttype), temp_uoid);
if(objecttoRefresh != null)
session.Refresh(objecttoRefresh);
The program reads the list with the updated objects, gets the object that needs to be updated and then updates it using the Refesh method.
Th updates work just fine but I've discovered a nasty problem.. Here is the scenario:
1) I open a form to update object A
2) At that tiem another application updates object A and writes update info to the database
3) While I'm still working on the form my application checks for updated objects and refreshes object A.
4) I'm done with the changes and click the update button to write my changes to object A.
5) The following exception occurs:
NHibernate.NonUniqueObjectException occurred
Message="a different object with the same identifier value was already associated with the session: 21, of class: DevorexKasa.domainObjects.contractor_natural"
Source="NHibernate"
StackTrace:
at NHibernate.Impl.SessionImpl.CheckUniqueness(Key key, Object obj)
at NHibernate.Impl.SessionImpl.DoUpdateMutable(Object obj, Object id, IClassPersister persister)
at NHibernate.Impl.SessionImpl.DoUpdate(Object obj, Object id, IClassPersister persister)
at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj)
at DevorexKasa.form_DevorexKasa.persistence_SaveUpdate(Object obj) in C:\Documents and Settings\Work\My Documents\Visual Studio 2005\Projects\DevorexKasa\DevorexKasa\Form1.cs:line 713
Why is that happening?
Did the object that I used in my form become detached?
As you can see when my application updates domain objects (
objecttoRefresh = session.Get(Type.GetType(temp_objecttype), temp_uoid);
if(objecttoRefresh != null)
session.Refresh(objecttoRefresh); ) it is not creating copies.
Could you give me a hint how to fix this?