So it will stay a mystery, at least for me, because I don't know what else i should say or describe.

The containing entity is a proxy:

Marker pTM = Session.Get(10847)

=> pTM.GetType().ToString() => "Castle.Proxies.MarkerProxy"

and again
using lazy="proxy" for the many-to-one property NH loads it on demand (when first accessed) using lazy="no-proxy" for the many-to-one property NH loads it immediately (before it is accessed for the first time)



Am schrieb Ricardo Peres <[email protected]>:
There are three types of proxies:



1 - Proxies to many-to-one entities (such as MyOtherEntity);

2 - Proxies to properties (such as String);

3 - Proxies to collections (such as ISet.



For the first two, you need the containing entity type to be marked as

lazy; this way, NHibernate will create a proxy for the entity type

(creating a class that inherits from it), and will replace those

properties marked as lazy (types 1 and 2), which have to be virtual,

with code that will only load them on demand, that is, when they are

first accessed. Marking a property of type 1 or 2 in a non-lazy entity

type will do exactly nothing.



RP





On May 20, 7:09 pm, Mohamed Meligy [email protected]> wrote:

> Interesting, so, this setting although does work / validate on many to one

> properties, is essentially useless for these?

>

> *Mohamed Meligy

> *Readify | Senior Developer

>

> M:+61 451 835006 | W: readify.net

> [image: Description: Description: Description: Description:

> rss_16]http://gurustop.net>

> [image: Description: Description: Description: Description:

> cid:[email protected]]

> http://www.linkedin.com/in/meligy> [image:

> Description: Description: Description: Description:

> cid:[email protected]] http://twitter.com/meligy>

> http://www.greatplacetowork.com.au/best/best-companies-australia.php>http://www.readify.net/AboutUs/NewsItem.aspx?id=10>

>

>

>

>

>

>

>

> On Sat, May 21, 2011 at 4:07 AM, Ricardo Peres [email protected]> wrote:

> > Is your entity marked as lazy?

> > If not, the only thing that can be lazy loaded (or proxied, if you

> > prefer) is one to many collections.

>

> > On May 20, 6:36 pm, Mohamed Meligy [email protected]> wrote:

> > > I have done some test now.

> > > Yeah, it "does" load the reference if you set lazy="no-proxy" although

> > the

> > > article says otherwise!!

> > > Are your entities marked as lazy

> > > *Mohamed Meligy

> > > *Readify | Senior Developer

>

> > > M:+61 451 835006 | W: readify.net

> > > [image: Description: Description: Description: Description:

> > > rss_16]http://gurustop.net>

> > > [image: Description: Description: Description: Description:

> > > cid:[email protected]]

> > > http://www.linkedin.com/in/meligy> [image:

> > > Description: Description: Description: Description:

> > > cid:[email protected]] http://twitter.com/meligy>

> > > http://www.greatplacetowork.com.au/best/best-companies-australia.php>
> >http://www.readify.net/AboutUs/NewsItem.aspx?id=10>

>

> > > On Sat, May 21, 2011 at 3:27 AM, [email protected]> wrote:

> > > > If I use "no-proxy" it should (and is) always be initialized, but it

> > should

> > > > not be loaded immedetialy from the DB (i think).

> > > > This is not a real issue for me right now, since what i wanted can be

> > > > accomplished using lazy="proxy", but i 'm really interested

> > > > in what the problem here is or what i'm doing wrong.

>

> > > > Am schrieb "H.Alex" [email protected]>:

>

> > > > > you can try testing with

>

> > > > > NHibernateUtil.IsInitialized(laizy property);

>

> > > > > On May 20, 12:12 pm, [email protected] wrote:

>

> > > > > > I don't think so beacuse in the first case ("proxy") => one query

> > is

>

> > > > > > executed

>

> > > > > > in the second case ("no-proxy") => two queries are executed

> > immediately

>

> > > > > > In the first case, the second query (for the Script property) is

> > only

>

> > > > > > executed, if i use the VS watch window

>

> > > > > > or something. This is the expected behaviour. But i thought this

> > should

> > > > be

>

> > > > > > the same if i use "no-proxy"

>

> > > > > > Am schrieb Mohamed Meligy [email protected]>:

>

> > > > > > > The query for the Script is then executed if i look at the

> > property

> > > > in

>

> > > > > > > the VS watch window.

>

> > > > > > > Maybe this is the reason? To get the property value, even in

> > Visual

>

> > > > > > > Studio watch window, the property getter is executed.

>

> > > > > > > Mohamed Meligy

>

> > > > > > > Readify | Senior Developer

>

> > > > > > > M:+61 451 835006 | W: readify.net

>

> > > > > > > On Fri, May 20, 2011 at 7:34 PM, [email protected]>

> > wrote:

>

> > > > > > > @mohamed

>

> > > > > > > to test this, i simply do

>

> > > > > > > Marker pTM = Session.Get(10824);

>

> > > > > > > and then check the sql output to the console. Using "proxy" only

> > one

>

> > > > > > > query is executed:

>

> > > > > > > NHibernate: SELECT marker0_.MARKER_ID as REPORTS1_282_2_...

>

> > > > > > > The query for the Script is then executed if i look at the

> > property

> > > > in

>

> > > > > > > the VS watch window.

>

> > > > > > > Using "no-proxy" the call to Get shows two executed queries, one

> > for

> > > > the

>

> > > > > > > Marker itself and the second for the Script:

>

> > > > > > > NHibernate: SELECT marker0_.MARKER_ID as REPORTS1_282_2_...

>

> > > > > > > NHibernate: SELECT script0_.SCRIPT_ID as T1_264_3_,

> > script0_.SC_DESCR

> > > > ...

>

> > > > > > > One guess was that the ID is the problem since this is a property

> > and

> > > > it

>

> > > > > > > will be touched to create the temp

>

> > > > > > > instance. So i changed it to

> > access="field.pascalcase-m-underscore"

> > > > but

>

> > > > > > > it did'nt solve the problem.

>

> > > > > > > Am schrieb Mohamed Meligy [email protected]>:

>

> > > > > > > > Ramon, this is not eager loading.

>

> > > > > > > > Quoting from the mentioned post:

>

> > > > > > > > When lazy is set to no-proxy, the following things happen:The

>

> > > > > > > association is still lazy loaded (note that in older versions of

>

> > > > > > > NHibernate, setting it to no-proxy would trigger eager loading,

> > this

> > > > is

>

> > > > > > > no longer the case).

>

> > > > > > > > The first time that you access the property the value will be

> > > > loaded

>

> > > > > > > from the database, and the actual type will be returned.

>

> > > > > > > > @belvasis,

>

> > > > > > > > How are checking this? Note that maybe even looking up the

> > value in

>

> > > > > > > debugger or Visual Studio Watch window triggers this. Are you

> > sure

> > > > your

>

> > > > > > > code is not touching the property in any way?

>

> > > > > > > > Can you isolate it and paste it in a letter message?

>

> > > > > > > > Thanks a lot.

>

> > > > > > > > Regards,

>

> > > > > > > > Mohamed Meligy

>

> > > > > > > > Readify | Senior Developer

>

> > > > > > > > M:+61 451 835006 | W: readify.net

>

> > > > > > > > On Fri, May 20, 2011 at 5:08 PM, Ramon Smits

> > [email protected]>

>

> > > > > > > wrote:

>

> > > > > > > > Hm i think i understand this. But shouldn't the behaviour be

> > the

> > > > same?

>

> > > > > > > Why "no-proxy" immediately queries

>

> > > > > > > > to the database?

>

> > > > > > > > As a proxy makes it possible to have delayed loading?

>

> > > > > > > > --

>

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

>

> > > > > > > > --

>

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

>

> > > > > > > --

>

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

>

> > > > > > > --

>

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

>

> > > > > --

>

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

>

> > > > --

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

>

> > --

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



--

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.




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

Reply via email to