And anyway, my first issue persists. I was able to reset default-lazy to false by using conventions. I don't put LazyLoad() on my class map and set it to my association only. I used WriteMappingsTo wo check that no lazy attribute is defined on the class and lazy="proxy" is defined on my association. With all that, my association is still eager loaded.
So would it be a NH issue instead of a FNH one ? N. On Jan 26, 10:57 am, VisualHint <cadil...@gmail.com> wrote: > I understand a bit better now but note that: > > 1. When I generate the hbm from FNH and both LazyLoad and > NotLazyLoaded are not set on the class, then no lazy attribute is > added to the hbm file which maybe contradicts what you say ("Fluent > NHibernate always sets something") > > 2. If your explanation is right, LazyLoad() on the association is > absolutely of no use. > > N. > > On Jan 26, 10:23 am, James Gregory <jagregory....@gmail.com> wrote: > > > That sounds correct to me. Whatever gets set on the class takes precedence > > over what you set in the relationship. > > HBM allowed you to not set anything for lazy load, while Fluent NHibernate > > always sets something; there's no way not to specify a value. So the lazy on > > the relationship is used when the entity doesn't have any kind of lazy > > setting, but if it does then it overrides whatever is set on the > > relationship; because FNH always sets a lazy value, it always overrides the > > relationship. > > > No bug here as far as I can tell, but the lazy on the references method is > > perhaps redundant. > > > On Mon, Jan 26, 2009 at 3:16 PM, VisualHint <cadil...@gmail.com> wrote: > > > > ok, so now that the default is lazy=true, I added NotLazyLoaded to my > > > classmap. I set LazyLoad on my association only and again it is not > > > lazy loaded. > > > If however, I remove NotLazyLoaded, then the default takes precedence > > > and with or without LazyLoad on my association, it is lazy loaded. > > > So I suspect something is wrong in the first case. The fault to NH > > > maybe (I'm with 2.1.0.1001). > > > > N. > > > > On Jan 26, 10:09 am, James Gregory <jagregory....@gmail.com> wrote: > > > > How are you getting your fluent mappings into nhibernate? default-lazy > > > > should definitely be true if you're running on the latest trunk. > > > > > On Mon, Jan 26, 2009 at 2:54 PM, VisualHint <cadil...@gmail.com> wrote: > > > > > > If I call System.Xml.XmlDocument doc = CreateMapping(new > > > > > FluentNHibernate.MappingVisitor()); > > > > > > I get an hbm that has default-lazy=false and I can assure you that I > > > > > got the latest FNH from the trunk, rebuilt it and referenced it. The > > > > > various lazy settings are correctly added in the xml file for the 2 > > > > > versions of LazyLoad() methods. > > > > > I don't touch to the conventions. > > > > > Configuration is done through the hibernate.cfg.xml and it contains > > > > > only the minimum: > > > > > > <?xml version="1.0" encoding="utf-8" ?> > > > > > <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> > > > > > <session-factory> > > > > > <property name="connection.connection_string">Server=. > > > > > \SQLEXPRESS;Database=mydb;Integrated Security=True;</property> > > > > > <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</ > > > > > property> > > > > > <property > > > > name="connection.provider">NHibernate.Connection.DriverConnectionProvider</ > > > > > property> > > > > > <property > > > > > name="connection.driver_class">NHibernate.Driver.SqlClientDriver</ > > > > > property> > > > > > <property name="connection.release_mode">auto</property> > > > > > <property name="adonet.batch_size">500</property> > > > > > > <property name="show_sql">true</property> > > > > > <property name="generate_statistics">true</property> > > > > > > </session-factory> > > > > > </hibernate-configuration> > > > > > > On Jan 26, 9:45 am, James Gregory <jagregory....@gmail.com> wrote: > > > > > > By default the "default-lazy" attribute is set to true on every > > > mapping > > > > > > created by Fluent NHibernate, so unless you've overridden this using > > > the > > > > > > conventions, that's what's getting set. As far as I understand, this > > > > > infers > > > > > > the class level setting. > > > > > > How are you configuring your session factory? Could you write out > > > your > > > > > > mappings using the WriteMappingsTo method of the PersistenceModel, > > > then > > > > > we > > > > > > can see what's actually being generated. > > > > > > > On Mon, Jan 26, 2009 at 1:58 PM, VisualHint <cadil...@gmail.com> > > > wrote: > > > > > > > > I use the latest FNH and it still doesn't work. I have to > > > explicitely > > > > > > > set LazyLoad on the classmap to get this behavior. > > > > > > > I understand the difference between the 2 lazyload methods but I > > > don't > > > > > > > understand when you say: > > > > > > > > > however, the class gets precedence, so if your class isn't set > > > > > > > > to lazy load (which was the default) then the references call > > > won't > > > > > have > > > > > > > any > > > > > > > > effect. > > > > > > > > Logically, if the entity is not forced to LazLoad then calling it > > > or > > > > > > > not on the association WOULD MAKE a difference. > > > > > > > If you force it on the classmap then calling LazyLoad on the > > > > > > > association would not change anything. If a NotLazyLoaded was > > > possible > > > > > > > on the association, then this one would make a difference. No? > > > > > > > > About trying with hbm, unfortunately, I tried to learn FNH before > > > HBM > > > > > > > so this is not something I can immediately try. > > > > > > > > N. > > > > > > > > On Jan 26, 7:14 am, James Gregory <jagregory....@gmail.com> wrote: > > > > > > > > @Nicolas: How old is your copy of Fluent NHibernate? Originally > > > it > > > > > was > > > > > > > the > > > > > > > > default that all entities would be not lazy loaded; so if your > > > copy > > > > > is > > > > > > > from > > > > > > > > then, you won't see the lazy load behaviour. > > > > > > > > The two different lazy load methods you spoke of do different > > > things, > > > > > the > > > > > > > > lazy load on the class sets it at the entity level, so whenever > > > that > > > > > > > entity > > > > > > > > is referenced anywhere it's lazy loaded, the other sets it for > > > that > > > > > > > specific > > > > > > > > relationship; however, the class gets precedence, so if your > > > class > > > > > isn't > > > > > > > set > > > > > > > > to lazy load (which was the default) then the references call > > > won't > > > > > have > > > > > > > any > > > > > > > > effect. > > > > > > > > > As Seb said, the reason the class lazy load requires virtual > > > methods > > > > > is > > > > > > > > because it creates a proxy of the entity. If your methods aren't > > > > > already > > > > > > > > virtual, then your lazy loading won't be working because > > > NHibernate > > > > > won't > > > > > > > > know how to track it. > > > > > > > > > So what do you need to do? Update your copy of FNH and try > > > > > > > > again, > > > > > failing > > > > > > > > that, explicitly set lazy loading in your class and use > > > > > > > > virtuals; > > > > > that's > > > > > > > the > > > > > > > > recommended approach. > > > > > > > > > Please note, this isn't a Fluent NHibernate specific issue, > > > > > > > > you'd > > > be > > > > > > > seeing > > > > > > > > the same behaviour for standard xml mapping too. > > > > > > > > > On Mon, Jan 26, 2009 at 8:57 AM, Paul Batum < > > > paul.ba...@gmail.com> > > > > > > > wrote: > > > > > > > > > When it comes to issues such as this I am somewhat of a broken > > > > > record - > > > > > > > my > > > > > > > > > suggestion is always the same: > > > > > > > > > > See if you can get the desired behavior using HBM xml. Once > > > > > > > > > you > > > > > have > > > > > > > > > working xml, we can compare it to what fluent nhibernate is > > > > > generating > > > > > > > and > > > > > > > > > see where the problem lies. > > > > > > > > > > Paul Batum > > > > > > > > > > On Mon, Jan 26, 2009 at 9:16 AM, Chris Marisic < > > > ch...@marisic.com> > > > > > > > wrote: > > > > > > > > > >> I noticed this also but I assumed I was handling the session > > > > > > > > >> incorrectly making it fully load the object but maybe this > > > > > actually is > > > > > > > > >> an issue. > > > > > > > > > >> On Jan 25, 9:20 am, VisualHint <cadil...@gmail.com> wrote: > > > > > > > > >> > Yes I know that Seb (thx anyway). This was just telling a > > > fact. > > > > > > > > >> > My question is about LazyLoad and why it has no effect when > > > > > called > > > > > > > on > > > > > > > > >> > a References() call. > > > > > > > > > >> > Nicolas > > > > > > > > > >> > On Jan 25, 3:44 am, Sebastien Lambla <s...@serialseb.com> > > > > > wrote: > > > > > > > > > >> > > > But doing that has a consequence: All my properties in> > > > the > > > > > > > "one" > > > > > > > > >> model must be virtual, even the ones that are not related to> > > > > > fields > > > > > > > in my > > > > > > > > >> database. > > > > > > > > > >> > > That's because the object is created as a proxy. Any of > > > your > > > > > > > property > > > > > > > > >> may have access or rely on other properties that need to be > > > > > hydrated > > > > > > > from > > > > > > > > >> the db. They all need to be virtual so that the first cal can > > > > > trigger > > > > > > > the > > > > > > > > >> load. This is an nhibernate thing. > > > > > > > > > >> > > -- > > > > > > > > >> > > Seb > > > > > > _________________________________________________________________ > > > > > > > > >> > > Windows Live Messenger just got better .Video display > > > pics, > > > > > > > contact > > > > > > > > >> updates & more.http://www.download.live.com/messenger --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibernate@googlegroups.com To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---