From: NHibernate J. <mik...@us...> - 2006-10-24 12:50:43
|
[ http://jira.nhibernate.org/browse/NH-423?page=comments#action_14167 ] John Chapman commented on NH-423: --------------------------------- This issue is not resolved. I have verified that it does exist in the nHibernate 1.0.2 codebase. I was able to work around this by using an HQL query and passing the value type primary keys of the object. I was previously using the Load method passing in the object with the existing keys when it threw an exception. The TransientObjectException only appeared after I added the version to the mapping file/class. Previously loading by Object worked fine. Note that in my case I am using a composite key of many-to-one types and that is why I was attempting to load using the object from the first session. The TransientObjectException was actually being thrown on one of the key object stating that it was transient and needed to be saved even though it was saved in the other session and already flushed by this point. The test looked something like the following: // Define the test object(s) ScheduleRun obj = Create(true, null); ScheduleRun savedObj = null; // Save the test object(s) Sessions[0].Flush(); // Start a new Session Sessions.New(); // Retrieve the test object(s) savedObj = (ScheduleRun)Sessions[1].Load(typeof(ScheduleRun), obj); Note that the Create method creates mock objects for this object and all many-to-one. The first parameter tells the create to using the Session.Save method on all created objects. The test fails (exception) on the last line where load is called. I would not call this a major bug since there is a relatively easy work around. Plus working with 2 sessions seems like a relatively rare occurance. > TransientObjectException when using an object from another session in a Query > ----------------------------------------------------------------------------- > > Key: NH-423 > URL: http://jira.nhibernate.org/browse/NH-423 > Project: NHibernate > Type: Bug > Components: Core > Versions: 1.0 > Reporter: Donald Mull > Attachments: Organization.hbm.xml > > When using an object from another session (loaded from the database) in a Query a TransientOBjectSession is thrown as if the object does not exist in the database. > Forum Thread: http://nhibernate.sourceforge.net/forum/viewtopic.php?t=1026 -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |