From: <aye...@us...> - 2010-01-25 07:33:07
|
Revision: 4927 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4927&view=rev Author: ayenderahien Date: 2010-01-25 07:33:00 +0000 (Mon, 25 Jan 2010) Log Message: ----------- Changing ghost property terminology from ghost to unwrap proxy (more accurate) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs trunk/nhibernate/src/NHibernate/Intercept/DefaultFieldInterceptor.cs trunk/nhibernate/src/NHibernate/Intercept/FieldInterceptionHelper.cs trunk/nhibernate/src/NHibernate/Mapping/Property.cs trunk/nhibernate/src/NHibernate/Tuple/Entity/EntityMetamodel.cs trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs trunk/nhibernate/src/NHibernate/Tuple/PocoInstantiator.cs trunk/nhibernate/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs 2010-01-24 22:44:45 UTC (rev 4926) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs 2010-01-25 07:33:00 UTC (rev 4927) @@ -107,7 +107,7 @@ var value = new ManyToOne(table); BindManyToOne(manyToOneMapping, value, propertyName, true); property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); - property.IsGhostProperty = manyToOneMapping.Lazy == HbmLaziness.NoProxy; + property.UnwrapProxy = manyToOneMapping.Lazy == HbmLaziness.NoProxy; BindManyToOneProperty(manyToOneMapping, property); } else if ((componentMapping = entityPropertyMapping as HbmComponent) != null) Modified: trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs 2010-01-24 22:44:45 UTC (rev 4926) +++ trunk/nhibernate/src/NHibernate/Intercept/AbstractFieldInterceptor.cs 2010-01-25 07:33:00 UTC (rev 4927) @@ -13,18 +13,18 @@ [NonSerialized] private ISessionImplementor session; private ISet<string> uninitializedFields; - private ISet<string> uninitializedGhostFieldNames; + private ISet<string> unwrapProxyFieldNames; private readonly string entityName; [NonSerialized] private bool initializing; private bool isDirty; - protected internal AbstractFieldInterceptor(ISessionImplementor session, ISet<string> uninitializedFields, ISet<string> uninitializedGhostFieldNames, string entityName) + protected internal AbstractFieldInterceptor(ISessionImplementor session, ISet<string> uninitializedFields, ISet<string> unwrapProxyFieldNames, string entityName) { this.session = session; this.uninitializedFields = uninitializedFields; - this.uninitializedGhostFieldNames = uninitializedGhostFieldNames; + this.unwrapProxyFieldNames = unwrapProxyFieldNames; this.entityName = entityName; } @@ -95,7 +95,7 @@ { return InitializeField(fieldName, target); } - if (value is INHibernateProxy && uninitializedGhostFieldNames != null && uninitializedGhostFieldNames.Contains(fieldName)) + if (value is INHibernateProxy && unwrapProxyFieldNames != null && unwrapProxyFieldNames.Contains(fieldName)) { return InitializeOrGetAssociation((INHibernateProxy)value); } Modified: trunk/nhibernate/src/NHibernate/Intercept/DefaultFieldInterceptor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Intercept/DefaultFieldInterceptor.cs 2010-01-24 22:44:45 UTC (rev 4926) +++ trunk/nhibernate/src/NHibernate/Intercept/DefaultFieldInterceptor.cs 2010-01-25 07:33:00 UTC (rev 4927) @@ -5,8 +5,8 @@ { public class DefaultFieldInterceptor : AbstractFieldInterceptor { - public DefaultFieldInterceptor(ISessionImplementor session, ISet<string> uninitializedFields, ISet<string> uninitializedGhostFieldNames, string entityName) - : base(session, uninitializedFields, uninitializedGhostFieldNames, entityName) + public DefaultFieldInterceptor(ISessionImplementor session, ISet<string> uninitializedFields, ISet<string> unwrapProxyFieldNames, string entityName) + : base(session, uninitializedFields, unwrapProxyFieldNames, entityName) { } } Modified: trunk/nhibernate/src/NHibernate/Intercept/FieldInterceptionHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Intercept/FieldInterceptionHelper.cs 2010-01-24 22:44:45 UTC (rev 4926) +++ trunk/nhibernate/src/NHibernate/Intercept/FieldInterceptionHelper.cs 2010-01-25 07:33:00 UTC (rev 4927) @@ -34,13 +34,13 @@ public static IFieldInterceptor InjectFieldInterceptor(object entity, string entityName, ISet<string> uninitializedFieldNames, - ISet<string> uninitializedGhostFieldNames, + ISet<string> unwrapProxyFieldNames, ISessionImplementor session) { var fieldInterceptorAccessor = entity as IFieldInterceptorAccessor; if (fieldInterceptorAccessor != null) { - var fieldInterceptorImpl = new DefaultFieldInterceptor(session, uninitializedFieldNames, uninitializedGhostFieldNames, entityName); + var fieldInterceptorImpl = new DefaultFieldInterceptor(session, uninitializedFieldNames, unwrapProxyFieldNames, entityName); fieldInterceptorAccessor.FieldInterceptor = fieldInterceptorImpl; return fieldInterceptorImpl; } Modified: trunk/nhibernate/src/NHibernate/Mapping/Property.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2010-01-24 22:44:45 UTC (rev 4926) +++ trunk/nhibernate/src/NHibernate/Mapping/Property.cs 2010-01-25 07:33:00 UTC (rev 4927) @@ -305,6 +305,6 @@ set { nodeName = value; } } - public bool IsGhostProperty { get; set; } + public bool UnwrapProxy { get; set; } } } Modified: trunk/nhibernate/src/NHibernate/Tuple/Entity/EntityMetamodel.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Tuple/Entity/EntityMetamodel.cs 2010-01-24 22:44:45 UTC (rev 4926) +++ trunk/nhibernate/src/NHibernate/Tuple/Entity/EntityMetamodel.cs 2010-01-25 07:33:00 UTC (rev 4927) @@ -153,9 +153,9 @@ { hasLazy = true; } - if (prop.IsGhostProperty) + if (prop.UnwrapProxy) { - hasGhostProperties = true; + hasUnwrapProxyForProperties = true; } propertyLaziness[i] = lazyProperty; @@ -238,12 +238,12 @@ VerifyCanInterceptPropertiesForLazyOrGhostProperties(persistentClass); } } - if(hasGhostProperties) + if(hasUnwrapProxyForProperties) { if (lazy == false) { log.WarnFormat("Disabled ghost properies fetching for {0} beacuse it does not support lazy at the entity level", name); - hasGhostProperties = false; + hasUnwrapProxyForProperties = false; } else { @@ -303,7 +303,7 @@ { foreach (var prop in persistentClass.PropertyClosureIterator) { - if (prop.IsLazy == false && prop.IsGhostProperty) + if (prop.IsLazy == false && prop.UnwrapProxy) continue; var getter = prop.GetGetter(persistentClass.MappedClass); @@ -683,7 +683,7 @@ #region Tuplizer private readonly EntityEntityModeToTuplizerMapping tuplizerMapping; - private bool hasGhostProperties; + private bool hasUnwrapProxyForProperties; public IEntityTuplizer GetTuplizer(EntityMode entityMode) { @@ -706,9 +706,9 @@ get { return naturalIdPropertyNumbers != null; } } - public bool HasGhostProperties + public bool HasUnwrapProxyForProperties { - get { return hasGhostProperties; } + get { return hasUnwrapProxyForProperties;c } } public bool HasNonIdentifierPropertyNamedId Modified: trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs 2010-01-24 22:44:45 UTC (rev 4926) +++ trunk/nhibernate/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs 2010-01-25 07:33:00 UTC (rev 4927) @@ -25,7 +25,7 @@ private readonly bool islifecycleImplementor; private readonly bool isValidatableImplementor; private readonly HashedSet<string> lazyPropertyNames = new HashedSet<string>(); - private readonly HashedSet<string> ghostPropertyNames = new HashedSet<string>(); + private readonly HashedSet<string> unwrapProxyPropertyNames = new HashedSet<string>(); [NonSerialized] private IReflectionOptimizer optimizer; private readonly IProxyValidator proxyValidator; @@ -55,8 +55,8 @@ { if (property.IsLazy) lazyPropertyNames.Add(property.Name); - if (property.IsGhostProperty) - ghostPropertyNames.Add(property.Name); + if (property.UnwrapProxy) + unwrapProxyPropertyNames.Add(property.Name); } SetReflectionOptimizer(); @@ -79,7 +79,7 @@ { get { - return (EntityMetamodel.HasLazyProperties || EntityMetamodel.HasGhostProperties) + return (EntityMetamodel.HasLazyProperties || EntityMetamodel.HasUnwrapProxyForProperties) && FieldInterceptionHelper.IsInstrumented(MappedClass); } } @@ -104,12 +104,12 @@ if (optimizer == null) { log.Debug("Create Instantiator without optimizer for:" + persistentClass.MappedClass.FullName); - return new PocoInstantiator(persistentClass, null, ProxyFactory, EntityMetamodel.HasLazyProperties || EntityMetamodel.HasGhostProperties); + return new PocoInstantiator(persistentClass, null, ProxyFactory, EntityMetamodel.HasLazyProperties || EntityMetamodel.HasUnwrapProxyForProperties); } else { log.Debug("Create Instantiator using optimizer for:" + persistentClass.MappedClass.FullName); - return new PocoInstantiator(persistentClass, optimizer.InstantiationOptimizer, ProxyFactory, EntityMetamodel.HasLazyProperties || EntityMetamodel.HasGhostProperties); + return new PocoInstantiator(persistentClass, optimizer.InstantiationOptimizer, ProxyFactory, EntityMetamodel.HasLazyProperties || EntityMetamodel.HasUnwrapProxyForProperties); } } @@ -229,7 +229,7 @@ HashedSet<string> lazyProps = lazyPropertiesAreUnfetched && EntityMetamodel.HasLazyProperties ? lazyPropertyNames : null; //TODO: if we support multiple fetch groups, we would need // to clone the set of lazy properties! - FieldInterceptionHelper.InjectFieldInterceptor(entity, EntityName, lazyProps, ghostPropertyNames, session); + FieldInterceptionHelper.InjectFieldInterceptor(entity, EntityName, lazyProps, unwrapProxyPropertyNames, session); } } Modified: trunk/nhibernate/src/NHibernate/Tuple/PocoInstantiator.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Tuple/PocoInstantiator.cs 2010-01-24 22:44:45 UTC (rev 4926) +++ trunk/nhibernate/src/NHibernate/Tuple/PocoInstantiator.cs 2010-01-25 07:33:00 UTC (rev 4927) @@ -22,7 +22,7 @@ private readonly IProxyFactory proxyFactory; - private readonly bool hasLazyProperties; + private readonly bool generateFieldInterceptionProxy; private readonly bool embeddedIdentifier; @@ -54,14 +54,14 @@ } } - public PocoInstantiator(PersistentClass persistentClass, IInstantiationOptimizer optimizer, IProxyFactory proxyFactory, bool hasLazyProperties) + public PocoInstantiator(PersistentClass persistentClass, IInstantiationOptimizer optimizer, IProxyFactory proxyFactory, bool generateFieldInterceptionProxy) { mappedClass = persistentClass.MappedClass; proxyInterface = persistentClass.ProxyInterface; embeddedIdentifier = persistentClass.HasEmbeddedIdentifier; this.optimizer = optimizer; this.proxyFactory = proxyFactory; - this.hasLazyProperties = hasLazyProperties; + this.generateFieldInterceptionProxy = generateFieldInterceptionProxy; try { @@ -88,7 +88,7 @@ { throw new InstantiationException("Cannot instantiate abstract class or interface: ", mappedClass); } - if (hasLazyProperties) + if (generateFieldInterceptionProxy) { return proxyFactory.GetFieldInterceptionProxy(); } Modified: trunk/nhibernate/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs 2010-01-24 22:44:45 UTC (rev 4926) +++ trunk/nhibernate/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs 2010-01-25 07:33:00 UTC (rev 4927) @@ -77,5 +77,18 @@ } } + [Test] + public void GhostPropertyMaintainIdentityMapUsingGet() + { + using (ISession s = OpenSession()) + { + var payment = s.Load<Payment>(1); + var order = s.Get<Order>(1); + + Assert.AreSame(order.Payment, payment); + } + } + + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |