From: Michael D. <mik...@us...> - 2004-09-27 03:42:20
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30054/src/NHibernate/Impl Modified Files: Tag: alpha_avalon-proxy QueryImpl.cs SessionImpl.cs Log Message: commit on the avalon-proxy branch of a semi-working (no serialization) of proxies yet. Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.44 retrieving revision 1.44.2.1 diff -C2 -d -r1.44 -r1.44.2.1 *** SessionImpl.cs 23 Sep 2004 13:08:59 -0000 1.44 --- SessionImpl.cs 27 Sep 2004 03:42:02 -0000 1.44.2.1 *************** *** 436,439 **** --- 436,440 ---- info.AddValue( "arrayHolders", arrayHolders, typeof(IdentityMap) ); } + #endregion *************** *** 470,486 **** // TODO: figure out why proxies are having problems. The enumerator appears to be throwing // a null reference exception when the proxiesByKey.Count==0 ! // foreach(object proxy in proxiesByKey.Values) ! // { ! // object proxy = proxyEnumer.Current; ! // if (proxy is HibernateProxy) ! // { ! // HibernateProxyHelper.GetLazyInitializer(proxy as HibernateProxy).SetSession(this); ! // } ! // else ! // { ! // // the proxy was pruned during the serialization process ! // proxiesByKey.Remove(proxy); ! // } ! // } foreach(EntityEntry e in entries.Values) --- 471,486 ---- // TODO: figure out why proxies are having problems. The enumerator appears to be throwing // a null reference exception when the proxiesByKey.Count==0 ! foreach(object proxy in proxiesByKey.Values) ! { ! if (proxy is INHibernateProxy) ! { ! NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy)proxy ).Session = this; ! } ! else ! { ! // the proxy was pruned during the serialization process ! proxiesByKey.Remove(proxy); ! } ! } foreach(EntityEntry e in entries.Values) *************** *** 611,617 **** public LockMode GetCurrentLockMode(object obj) { ! if ( obj is HibernateProxy ) { ! obj = (HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj)).GetImplementation(this); if (obj==null) return LockMode.None; } --- 611,617 ---- public LockMode GetCurrentLockMode(object obj) { ! if ( obj is INHibernateProxy ) { ! obj = (NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj)).GetImplementation(this); if (obj==null) return LockMode.None; } *************** *** 905,910 **** private void ReassociateProxy(Object value) { ! HibernateProxy proxy = (HibernateProxy) value; ! LazyInitializer li = HibernateProxyHelper.GetLazyInitializer(proxy); ReassociateProxy(li, proxy); } --- 905,910 ---- private void ReassociateProxy(Object value) { ! INHibernateProxy proxy = (INHibernateProxy) value; ! LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer(proxy); ReassociateProxy(li, proxy); } *************** *** 912,919 **** private object UnproxyAndReassociate(object maybeProxy) { ! if ( maybeProxy is HibernateProxy ) { ! HibernateProxy proxy = (HibernateProxy) maybeProxy; ! LazyInitializer li = HibernateProxyHelper.GetLazyInitializer(proxy); ReassociateProxy(li, proxy); return li.GetImplementation(); //initialize + unwrap the object --- 912,919 ---- private object UnproxyAndReassociate(object maybeProxy) { ! if ( maybeProxy is INHibernateProxy ) { ! INHibernateProxy proxy = (INHibernateProxy) maybeProxy; ! LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer(proxy); ReassociateProxy(li, proxy); return li.GetImplementation(); //initialize + unwrap the object *************** *** 930,934 **** /// <param name="li"></param> /// <param name="proxy"></param> ! private void ReassociateProxy(LazyInitializer li, HibernateProxy proxy) { if ( li.Session!=this ) --- 930,934 ---- /// <param name="li"></param> /// <param name="proxy"></param> ! private void ReassociateProxy(LazyInitializer li, INHibernateProxy proxy) { if ( li.Session!=this ) *************** *** 937,941 **** Key key = new Key( li.Identifier, persister ); if ( !proxiesByKey.Contains(key) ) proxiesByKey[key] = proxy; // any earlier proxy takes precedence ! HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) proxy ).SetSession(this); } } --- 937,941 ---- Key key = new Key( li.Identifier, persister ); if ( !proxiesByKey.Contains(key) ) proxiesByKey[key] = proxy; // any earlier proxy takes precedence ! NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) proxy ).Session = this; } } *************** *** 1001,1008 **** private bool IsUnsaved(object obj, bool earlyInsert, object self) { ! if ( obj is HibernateProxy ) { // if its an uninitialized proxy, it can't be transietn ! LazyInitializer li = HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj ); if ( li.GetImplementation(this)==null ) { --- 1001,1008 ---- private bool IsUnsaved(object obj, bool earlyInsert, object self) { ! if ( obj is INHibernateProxy ) { // if its an uninitialized proxy, it can't be transietn ! LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ); if ( li.GetImplementation(this)==null ) { *************** *** 1470,1476 **** if (obj==null) throw new NullReferenceException("attempted to update null"); ! if ( obj is HibernateProxy ) { ! object pid = HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj ).Identifier; if( !id.Equals(pid) ) throw new HibernateException("The given proxy had a different identifier value to the given identifier: " + pid + "!=" + id); --- 1470,1476 ---- if (obj==null) throw new NullReferenceException("attempted to update null"); ! if ( obj is INHibernateProxy ) { ! object pid = NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ).Identifier; if( !id.Equals(pid) ) throw new HibernateException("The given proxy had a different identifier value to the given identifier: " + pid + "!=" + id); *************** *** 1879,1885 **** public object ProxyFor(IClassPersister persister, Key key, object impl) { ! if ( !persister.HasProxy ) return impl; object proxy = proxiesByKey[key]; ! if (proxy!=null) { return NarrowProxy(proxy, persister, key, impl); --- 1879,1891 ---- public object ProxyFor(IClassPersister persister, Key key, object impl) { ! // added key==null because the java version of HashMap allows ! // a null key, but an IDictionary does not ! if( !persister.HasProxy || key==null ) ! { ! return impl; ! } ! object proxy = proxiesByKey[key]; ! if( proxy!=null ) { return NarrowProxy(proxy, persister, key, impl); *************** *** 2058,2067 **** 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; --- 2064,2069 ---- if ( persister.HasProxy ) { ! IProxyGenerator generator = ProxyGeneratorFactory.GetProxyGenerator(); ! proxy = generator.GetProxy( clazz, persister.ProxyInterfaces, persister.ProxyIdentifierProperty, id, this ); } proxiesByKey[key] = proxy; *************** *** 2685,2691 **** public object GetIdentifier(object obj) { ! if (obj is HibernateProxy) { ! LazyInitializer li = HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj ); if ( li.Session!=this ) throw new TransientObjectException("The proxy was not associated with this session"); return li.Identifier; --- 2687,2693 ---- public object GetIdentifier(object obj) { ! if (obj is INHibernateProxy) { ! LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ); if ( li.Session!=this ) throw new TransientObjectException("The proxy was not associated with this session"); return li.Identifier; *************** *** 2707,2713 **** public object GetEntityIdentifier(object obj) { ! if (obj is HibernateProxy) { ! return HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj ).Identifier; } else --- 2709,2715 ---- public object GetEntityIdentifier(object obj) { ! if (obj is INHibernateProxy) { ! return NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ).Identifier; } else *************** *** 2720,2724 **** public bool IsSaved(object obj) { ! if(obj is HibernateProxy) return true; EntityEntry entry = GetEntry(obj); --- 2722,2726 ---- public bool IsSaved(object obj) { ! if(obj is INHibernateProxy) return true; EntityEntry entry = GetEntry(obj); *************** *** 2748,2754 **** if (obj==null) return null; ! if (obj is HibernateProxy) { ! return HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj ).Identifier; } else --- 2750,2756 ---- if (obj==null) return null; ! if (obj is INHibernateProxy) { ! return NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ).Identifier; } else *************** *** 3802,3808 **** public bool Contains(object obj) { ! if (obj is HibernateProxy) { ! return HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj ).Session==this; } else --- 3804,3810 ---- public bool Contains(object obj) { ! if (obj is INHibernateProxy) { ! return NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ).Session==this; } else *************** *** 3819,3825 **** public void Evict(object obj) { ! if (obj is HibernateProxy) { ! LazyInitializer li = HibernateProxyHelper.GetLazyInitializer( (HibernateProxy) obj ); object id = li.Identifier; IClassPersister persister = GetPersister( li.PersistentClass ); --- 3821,3827 ---- public void Evict(object obj) { ! if (obj is INHibernateProxy) { ! LazyInitializer li = NHibernateProxyHelper.GetLazyInitializer( (INHibernateProxy) obj ); object id = li.Identifier; IClassPersister persister = GetPersister( li.PersistentClass ); Index: QueryImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/QueryImpl.cs,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -C2 -d -r1.14 -r1.14.2.1 *** QueryImpl.cs 22 Aug 2004 06:25:06 -0000 1.14 --- QueryImpl.cs 27 Sep 2004 03:42:02 -0000 1.14.2.1 *************** *** 152,156 **** } public IQuery SetEntity(int position, object val) { ! SetParameter(position, val, NHibernate.Entity( HibernateProxyHelper.GetClass(val))); return this; } --- 152,156 ---- } public IQuery SetEntity(int position, object val) { ! SetParameter(position, val, NHibernate.Entity( NHibernateProxyHelper.GetClass(val))); return this; } *************** *** 224,228 **** } public IQuery SetEntity(string name, object val) { ! SetParameter(name, val, NHibernate.Entity( HibernateProxyHelper.GetClass( val ) ) ); return this; } --- 224,228 ---- } public IQuery SetEntity(string name, object val) { ! SetParameter(name, val, NHibernate.Entity( NHibernateProxyHelper.GetClass( val ) ) ); return this; } *************** *** 243,247 **** private IType GuessType(object param) { ! System.Type clazz = HibernateProxyHelper.GetClass(param); return GuessType(clazz); } --- 243,247 ---- private IType GuessType(object param) { ! System.Type clazz = NHibernateProxyHelper.GetClass(param); return GuessType(clazz); } |