I decided to make it a new topic...
I have lazy initialization in a Data class:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Pix.Data.Data, Pix.Data" table="PICTURE" lazy="true">
<id name="Id" column="ID" type="Int32"
unsaved-value="0"access="field">
<generator class="sequence">
<param name="sequence">OBJECT_ID_GEN</param>
</generator>
</id>
<property name="Bytes" column="IMAGE" type="BinaryBlob"
access="field" />
<one-to-one name="Owner" class="Pix.Data.Picture, Pix.Data"
access="field" />
</class>
</hibernate-mapping>
Great... But now when I read my stored Picture object, I do NOT have Data field being initialized. Can anyone explain it to me? Does the generic proxy implementation in NHibernate (it is Castle, isn't i?) work with fields? If it does then why just simple invokation:
Code:
void Read(ISession sess, int id)
{
Picture pic = (Picture)sess.Load(typeof(Picture), id);
ShowPicture(pic.Data.Bytes);
}
doesn't work? The Data property has been initialized (I see it is just the proxy), but the data in it is NOT. Owner is null, id is zero, Bytes is null.
When I don't use lazy loading then it works :|
For more details on the design please see my previous topic related to one-to-one relationship at
http://forum.hibernate.org/viewtopic.php?t=953923
TIA