Just add lazy=proxy or lazy=no-proxy to the one-to-one declaration. The whole class must be lazy and the the properties must be virtual.
RP On Tuesday, May 14, 2013 1:41:10 PM UTC+1, Stefan wrote: > > Hi , > > Thank you for your suggestion. You example is not "lazy-loaded". > NHibernate will issue an outer join query from LOT to LOT_INDICATEUR when > you access a property of LOT. This is not what i want. I want a select for > LOT_INDICATEUR to be issue ONLY when i am accesing that property from LOT. > > Regards > > On Tuesday, May 14, 2013 3:54:24 AM UTC-5, Frédéric Delaporte wrote: >> >> Hello, >> I do not understand why do you need to map your one-to-one through bags >> for "performance consideration". I have a classical one-to-one with one end >> nullable, with lazy-loading enabled. And it works fine, even when the >> nullable end is null. (Batching seems not to be implemented on one-to-one >> though, I see separated queries for lazy-loading on each access.) >> >> Here is the mapping (xml, I do not known the "by code" syntax) I have for >> that : >> "master table" (responsible for the primary key) : >> <class name="Lot" table="LOT" mutable="false" batch-size="20"> >> <cache usage="read-only" /> >> <id name="Id" column="REF_LOT"> >> <generator class="identity"/> <!-- or whatever you want but not foreign >> --> >> </id> >> >> <!-- misc stuff ... --> >> >> <one-to-one name="Indicateurs" class="LotIndicateur" /> >> >> <!-- misc stuff ... --> >> </class> >> >> "child table" (having its primary key foreign from "master") : >> <class name="LotIndicateur" table="LOT_INDICATEUR" mutable="true" >> batch-size="20"> >> <id name="Id" column="REF_LOT"> >> <generator class="foreign"> >> <param name="property">Lot</param> >> </generator> >> </id> >> <one-to-one name="Lot" class="Lot" constrained="true" /> >> >> <!-- misc stuff ... --> >> </class> >> >> Le lundi 13 mai 2013 16:54:50 UTC+2, Stefan a écrit : >>> >>> I am trying to map a legacy bidirectional one-to-one with shared PK >>> using 2 bags. One end of the relation can be null. >>> >>> The reason i am doing this is for performance consideration (mostly to >>> provide lazy-loading). I have tried doing this with many-to-one but i get >>> all kind of strange issues plus i always need to check for an invalid proxy >>> due to the possibility that there is no associated record in one end of the >>> relation. >>> >>> >>> -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
