OK that issue may actually be mapping related. You coud change your mapping to <many-to-one name="enterprise" column="Enterprise" fetch="join" /> to force loading enterprise with Promotion every time.
Tomasz On 25 Mar, 23:28, Tomek Pluskiewicz <[email protected]> wrote: > Your issue is not really mapping related. > > Simply don't close ISession while you need your objects. Or eagerly > load any associated objects and collections before closing it... > > Also (please someone correct me if I'm wrong), if you load an object > from DB and close your session you can later open a new one and access > related objects then. > > Regards > Tomasz > > On 25 Mar, 22:41, SO King Fai <[email protected]> wrote: > > > > > > > > > And the Class Promotion is: > > public class Promotion > > { > > public virtual long promotionid { get; set; } > > public virtual long enterpriseid { get; set; } > > public virtual string promotionproduct { get; set; } > > public virtual string promotiondescription { get; set; } > > public virtual string promotionwebsite { get; set; } > > public virtual long clickthroughcount { get; set; } > > public virtual string promotionpublishdate { get; set; } > > public virtual Enterprise enterprise { get; set; } > > } > > > On Mar 26, 5:37 am, SO King Fai <[email protected]> wrote: > > > > Hello all I am a very newbie of NH I am facing a problem about using > > > NH. > > > > I have some class that have many-to-one mapping > > > However, I found that the internal implementation of NH. > > > It will have a Proxy class create at run-time and all object instance > > > will get by the Proxy class on demand. > > > However, if the Session is closed, the Proxy cannot request the object > > > instance and more. > > > > Any idea to fix it??? > > > > I want to try to google it but i even don't know what keyword i need > > > in order to google the problem. OTL > > > > Thank you very much > > > > For Example > > > > I have a Mapping Class: > > > <class name="Promotion"> > > > <id name="promotionid"> > > > <generator class="identity" /> > > > </id> > > > <property name="enterpriseid" column="Enterprise"/> > > > <property name="promotionproduct" /> > > > <property name="promotiondescription" /> > > > <property name="promotionwebsite" /> > > > <property name="clickthroughcount" /> > > > <property name="promotionpublishdate" /> > > > <many-to-one name="enterprise" column="Enterprise" /> > > > </class> > > > > and the Domain Class is: > > > public class Enterprise > > > { > > > public virtual long enterpriseid { get; set; } > > > public virtual string enterprisename { get; set; } > > > public virtual string loginname { get; set; } > > > public virtual string password { get; set; } > > > } > > > > If I get a object of Promotion by calling a function getPromotionByID > > > (of course it will be more complicated in my function) > > > And then outside the getPromotionByID > > > when i use the object promotion.enterprise.Value; > > > but i use promotion.Value is OK because the value is not request from > > > NH on demand. > > > then exception will be thrown say no Session something..... -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
