The same for one-to-one ? 2010/1/24 Ayende Rahien <[email protected]>
> Not much when there is that level of hand holding :-) > > > On Mon, Jan 25, 2010 at 12:50 AM, Fabio Maulo <[email protected]>wrote: > >> Ups!!! pretty quickly despite SVN >> >> >> 2010/1/24 Ayende Rahien <[email protected]> >> >>> Implemented & committed >>> >>> >>> On Mon, Jan 25, 2010 at 12:22 AM, Fabio Maulo <[email protected]>wrote: >>> >>>> Yes I know and for that reason is lazy="no-proxy". >>>> The many-to-one relationship has 3 possible lazy values : >>>> lazy="false" (this is to avoid lazy) >>>> lazy="proxy" (as we are working today) >>>> lazy="no-proxy" (the property will work as lazy-load but without the >>>> proxy) >>>> >>>> In the trunk we are "ignoring" the value no-proxy, interpreting it as >>>> lazy="false", but its behaviour should be exactly what you are >>>> implementing. >>>> >>>> >>>> 2010/1/24 Ayende Rahien <[email protected]> >>>> >>>>> This is not for avoiding lazy loading. >>>>> This is to allow lazy loading with the correct polymorphic type >>>>> >>>>> >>>>> On Mon, Jan 25, 2010 at 12:11 AM, Fabio Maulo <[email protected]>wrote: >>>>> >>>>>> I'm sorry I don't understand... >>>>>> We should have lazy="no-proxy" available for this scope. >>>>>> >>>>>> 2010/1/24 Ayende Rahien <[email protected]> >>>>>> >>>>>> Okay, >>>>>>> I just committed initial support for this. >>>>>>> Given the following mapping: >>>>>>> <class name="Order" table="Orders"> >>>>>>> <id name="Id"> >>>>>>> <generator class="assigned" /> >>>>>>> </id> >>>>>>> <many-to-one name="Payment" *force-load-on-property-access="true"*/> >>>>>>> </class> >>>>>>> >>>>>>> >>>>>>> <class name="Payment" abstract="true"> >>>>>>> <id name="Id"> >>>>>>> <generator class="assigned" /> >>>>>>> </id> >>>>>>> <discriminator column="Type" type="System.String"/> >>>>>>> <subclass name="WireTransfer" discriminator-value="WT"> >>>>>>> </subclass> >>>>>>> <subclass name="CreditCard" discriminator-value="CC"> >>>>>>> >>>>>>> </subclass> >>>>>>> >>>>>>> </class> >>>>>>> >>>>>>> The following test will pass: >>>>>>> >>>>>>> [Test] >>>>>>> public void CanGetActualValueFromLazyManyToOne() >>>>>>> { >>>>>>> using (ISession s = OpenSession()) >>>>>>> { >>>>>>> var order = s.Get<Order>(1); >>>>>>> >>>>>>> Assert.IsTrue(order.Payment is WireTransfer); >>>>>>> } >>>>>>> } >>>>>>> >>>>>>> There is one problem, though, and that is the identity map. >>>>>>> >>>>>>> public void GhostPropertyMaintainIdentityMap() >>>>>>> { >>>>>>> using (ISession s = OpenSession()) >>>>>>> { >>>>>>> var order = s.Get<Order>(1); >>>>>>> >>>>>>> Assert.AreSame(order.Payment, s.Load<Payment>(1)); >>>>>>> } >>>>>>> } >>>>>>> >>>>>>> This seems to all works. >>>>>>> >>>>>>> Thoughts? >>>>>>> >>>>>>> BTW, I really don't like the force-load-on-property-access, how about >>>>>>> call it ghost="false" ? >>>>>>> >>>>>>> On Thu, Dec 31, 2009 at 11:32 AM, Ayende Rahien >>>>>>> <[email protected]>wrote: >>>>>>> >>>>>>>> I am trying to figure out if we can support the following: >>>>>>>> >>>>>>>> class Comment >>>>>>>> { >>>>>>>> public virtual Post Post {get;set;} >>>>>>>> } >>>>>>>> >>>>>>>> class Post {} >>>>>>>> class Article : Post {} >>>>>>>> >>>>>>>> And *not* generate a PostProxy for the property, but instead detect >>>>>>>> the property access, force a load to return the correct type. >>>>>>>> We can do it right now by specifying lazy=false, but that pre-load >>>>>>>> the entity, while I would like to try to get it to load only on access >>>>>>>> time. >>>>>>>> >>>>>>>> There are several potential problems with this: >>>>>>>> a) we need to replace the reference on first access, which means >>>>>>>> that the _parent_ must be a proxy as well. >>>>>>>> b) we disallow field access entirely. >>>>>>>> c) identity map issues? >>>>>>>> >>>>>>>> other thoughts? >>>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Fabio Maulo >>>>>> >>>>>> >>>>> >>>> >>>> >>>> -- >>>> Fabio Maulo >>>> >>>> >>> >> >> >> -- >> Fabio Maulo >> >> > -- Fabio Maulo
