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
