[fluent-nhib] Re: Need some explanations about LazyLoad method

2009-01-26 Thread VisualHint

Thanks for all James.

I will just add that there is something missing in the FNH API. Since
one have to set the class as LazyLoad to really get lazy loading
working on an association, one also needs a way to invalidate the lazy
loading on a single association, something like:

References<...>().NotLazyLoaded()

which would add the lazy="false" on the association (I tried it
manually with a SetAttribute and it works well).

On Jan 26, 12:53 pm, James Gregory  wrote:
> In this case yes, because References/many-to-one isn't a collection;
> NHibernate needs the properties to be virtual so it can create a proxy to
> detect when something tries to access the referenced object, at which point
> it can go fetch the actual data.
>
> On Mon, Jan 26, 2009 at 5:25 PM,  wrote:
>
> > So it's not possible to only lazy load associations/collections, the
> > entire class has to be marked lazy load with every property set to
> > virtual?
>
> > On Jan 26, 12:07 pm, James Gregory  wrote:
> > > I don't think this is an issue, you just have to set lazy on the class;
> > > that's just how it's done. If you don't set lazy on the class, NHibernate
> > > has no way of lazy loading it as it won't know how to create the proxy.
>
> > > On Mon, Jan 26, 2009 at 4:54 PM, VisualHint  wrote:
>
> > > > 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  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  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 
> > > > 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 
> > wrote:
> > > > > > > > How are you getting your fluent mappings into nhibernate?
> > > > default-lazy
> > > > > > > > should definitely be true if you're running on the latest
> > trunk.
>
> > >

[fluent-nhib] Re: Need some explanations about LazyLoad method

2009-01-26 Thread VisualHint

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  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  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  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  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  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:
>
> > > > > 
> > > > > 
> > > > >  
> > > > >    Server=.
> > > > > \SQLEXPRESS;Database=mydb;Integrated Security=True;
> > > > >    NHibernate.Dialect.MsSql2005Dialect > > > > property>
> > > > >    
> > > name="connection.provider">NHibernate.Connection.DriverConnectionProvider > > > > property>
> > > > >     > > > > name="connection.driver_class">NHibernate.Driver.SqlClientDriver > > > > property>
> > > > >    auto
> > > > >    500
>
> > > > >    true
> > > > >    true
>
> > > > >  
> > > > > 
>
> > > > > On Jan 26, 9:45 am, James Gregory  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, Visu

[fluent-nhib] Re: Need some explanations about LazyLoad method

2009-01-26 Thread VisualHint

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  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  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  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  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:
>
> > > > 
> > > > 
> > > >  
> > > >    Server=.
> > > > \SQLEXPRESS;Database=mydb;Integrated Security=True;
> > > >    NHibernate.Dialect.MsSql2005Dialect > > > property>
> > > >    
> > name="connection.provider">NHibernate.Connection.DriverConnectionProvider > > > property>
> > > >     > > > name="connection.driver_class">NHibernate.Driver.SqlClientDriver > > > property>
> > > >    auto
> > > >    500
>
> > > >    true
> > > >    true
>
> > > >  
> > > > 
>
> > > > On Jan 26, 9:45 am, James Gregory  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 
> > 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
> > >

[fluent-nhib] Re: Need some explanations about LazyLoad method

2009-01-26 Thread VisualHint

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  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  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:
>
> > 
> > 
> >  
> >    Server=.
> > \SQLEXPRESS;Database=mydb;Integrated Security=True;
> >    NHibernate.Dialect.MsSql2005Dialect > property>
> >     > name="connection.provider">NHibernate.Connection.DriverConnectionProvider > property>
> >     > name="connection.driver_class">NHibernate.Driver.SqlClientDriver > property>
> >    auto
> >    500
>
> >    true
> >    true
>
> >  
> > 
>
> > On Jan 26, 9:45 am, James Gregory  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  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  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 

[fluent-nhib] Re: Need some explanations about LazyLoad method

2009-01-26 Thread VisualHint

Just after writing my last message I wondered: "if he tells me it
should be true, then I am certainly doing something wrong with
referencing the latest FNH". So I did it again, and you're right, it
defaults to true now. So from here, I will redo all my tests and
report.

On Jan 26, 10:09 am, James Gregory  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  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:
>
> > 
> > 
> >  
> >    Server=.
> > \SQLEXPRESS;Database=mydb;Integrated Security=True;
> >    NHibernate.Dialect.MsSql2005Dialect > property>
> >     > name="connection.provider">NHibernate.Connection.DriverConnectionProvider > property>
> >     > name="connection.driver_class">NHibernate.Driver.SqlClientDriver > property>
> >    auto
> >    500
>
> >    true
> >    true
>
> >  
> > 
>
> > On Jan 26, 9:45 am, James Gregory  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  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  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 

[fluent-nhib] Re: Need some explanations about LazyLoad method

2009-01-26 Thread VisualHint

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:



  
Server=.
\SQLEXPRESS;Database=mydb;Integrated Security=True;
NHibernate.Dialect.MsSql2005Dialect
NHibernate.Connection.DriverConnectionProvider
NHibernate.Driver.SqlClientDriver
auto
500

true
true

  



On Jan 26, 9:45 am, James Gregory  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  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  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 
> > 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 
> > 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  wrote:
> > > >> > Yes I know that Seb (thx anyway). This was just telling a fact.
> > > >> > My questi

[fluent-nhib] Re: Need some explanations about LazyLoad method

2009-01-26 Thread VisualHint

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  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  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  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  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  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
-~--~~~~--~~--~--~---



[fluent-nhib] Re: Need some explanations about LazyLoad method

2009-01-25 Thread VisualHint

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  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
-~--~~~~--~~--~--~---



[fluent-nhib] Need some explanations about LazyLoad method

2009-01-24 Thread VisualHint

Hi,

NH newbie here. I already posted a related question on stackoverflow
(http://stackoverflow.com/questions/476405/nhibernate-cant-
successfully-set-lazy-loading).

My issue is that putting LazyLoad() on a References() does not lazy
load the target of the reference (I see it in the generated sql).
After I asked my question on SO, I discovered that I was able to call
LazyLoad on the ClassMap instance (the "one" of my many-to-one
relationship). 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.

So why a simple call to LazyLoad() on a References() does not affect
lazy loading ?

What are the differences about the 2 LazyLoad calls ?

Thanks

Nicolas

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---