From: Michael D. <mik...@us...> - 2004-06-24 15:29:35
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6323/NHibernate/Impl Modified Files: SessionImpl.cs Log Message: The Session has been modified to not fail when loading an object with a proxy specified. Now it just ignores the proxy and loads the object anyway. Did this so we could start working on more of the test until I get the proxy going. This is _not_ a working proxy - it is the same as not having a proxy specified. Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** SessionImpl.cs 23 Jun 2004 21:11:41 -0000 1.28 --- SessionImpl.cs 24 Jun 2004 15:29:25 -0000 1.29 *************** *** 1983,2004 **** } ! /** ! * Load the data for the object with the specified id into a newly created ! * object. A new key will be assigned to the object. If the class supports ! * lazy initialization, return a proxy instead, leaving the real work for ! * later. This should return an existing proxy where appropriate. ! */ ! private object DoLoadByClass(System.Type clazz, object id, bool checkDeleted, bool allowProxyCreation) { ! if ( log.IsDebugEnabled ) log.Debug( "loading " + MessageHelper.InfoString(clazz, id) ); IClassPersister persister = GetPersister(clazz); ! if ( !persister.HasProxy ) { // this class has no proxies (so do a shortcut) return DoLoad(clazz, id, null, LockMode.None, checkDeleted); ! } else { Key key = new Key(id, persister); object proxy = null; ! if ( GetEntity(key)!=null ) { // return existing object or initialized proxy (unless deleted) return ProxyFor( --- 1983,2014 ---- } ! /// <summary> ! /// Load the data for the object with the specified id into a newly created ! /// object. A new key will be assigned to the object. If the class supports ! /// lazy initialization, return a proxy instead, leaving the real work for ! /// later. This should return an existing proxy where appropriate. ! /// </summary> ! /// <param name="clazz"></param> ! /// <param name="id"></param> ! /// <param name="checkDeleted"></param> ! /// <param name="allowProxyCreation"></param> ! /// <returns></returns> ! private object DoLoadByClass(System.Type clazz, object id, bool checkDeleted, bool allowProxyCreation) ! { if ( log.IsDebugEnabled ) log.Debug( "loading " + MessageHelper.InfoString(clazz, id) ); IClassPersister persister = GetPersister(clazz); ! if ( !persister.HasProxy ) ! { // this class has no proxies (so do a shortcut) return DoLoad(clazz, id, null, LockMode.None, checkDeleted); ! } ! else ! { Key key = new Key(id, persister); object proxy = null; ! ! if ( GetEntity(key)!=null ) ! { // return existing object or initialized proxy (unless deleted) return ProxyFor( *************** *** 2007,2026 **** DoLoad(clazz, id, null, LockMode.None, checkDeleted) ); ! } else if ( ( proxy = proxiesByKey[key] ) != null ) { // return existing uninitizlied proxy return NarrowProxy(proxy, persister, key, null); ! } else if ( allowProxyCreation ) { ! // retunr new uninitailzed proxy ! if ( persister.HasProxy ) { ! proxy = null; //TODO: Create the proxy ! // this is the spot that is causing the problems with FooBarTest.FetchInitializedCollection ! // when the following code "Assert.IsTrue( baz.fooBag.Count==2 );" is being executed. This ! // is causing a null value to be returned when a "Proxied" version of the class is expected. ! // So the method ThrowObjectNotFound is throwing an exception because it is given a null object ! // - hence the error looks like it can't find a row in the DB. ! } ! proxiesByKey[key] = proxy; ! return proxy; ! } else { // return a newly loaded object return DoLoad(clazz, id, null, LockMode.None, checkDeleted); --- 2017,2048 ---- DoLoad(clazz, id, null, LockMode.None, checkDeleted) ); ! } ! else if ( ( proxy = proxiesByKey[key] ) != null ) ! { // return existing uninitizlied proxy return NarrowProxy(proxy, persister, key, null); ! } ! else if ( allowProxyCreation ) ! { ! ! return DoLoad(clazz, id, null, LockMode.None, checkDeleted); ! ! // return new uninitailzed proxy ! //TODO: commented this out so we could get all of the test running - this basically makes ! // the proxy of a class be ignored - which is fine until we have it working. ! // if ( persister.HasProxy ) ! // { ! // proxy = null; //TODO: Create the proxy ! // // this is the spot that is causing the problems with FooBarTest.FetchInitializedCollection ! // // when the following code "Assert.IsTrue( baz.fooBag.Count==2 );" is being executed. This ! // // is causing a null value to be returned when a "Proxied" version of the class is expected. ! // // So the method ThrowObjectNotFound is throwing an exception because it is given a null object ! // // - hence the error looks like it can't find a row in the DB. ! // } ! // proxiesByKey[key] = proxy; ! // return proxy; ! } ! else ! { // return a newly loaded object return DoLoad(clazz, id, null, LockMode.None, checkDeleted); |