-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Proxy returned when calling Load
PostPosted: Wed Oct 18, 2006 8:06 am 
Newbie

Joined: Mon Jul 18, 2005 7:45 am
Posts: 16
When I call

Session.Load(objectType, id);

for one of my entity types (which is configured to be lazy) it appears that NHibernate is returning a Proxy to the instance - i.e. the entity type is:

Domain.Account

but the returned instance type is

CProxyTypeAccountDomain_INHibernateProxy_ISerializable2

I understand the the principal of using proxies to lazy load objects that are associated with a root object, but I'm unclear as to why a proxy would be returned when I am directly loading the object.

I think I can work around this issue OK, but I was hoping someone could clarify what is going on here - is there any benefit in using a proxy here and is this the expected behaviour?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 6:00 pm 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
Load will always return a proxy if the object is mapped as lazy. If you want to get the object use Get instead.

If you need to know the underlying type of the object use the NHibernateUtil.GetClass method on the proxy object.

Symon.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.