-->
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: nullable proxied objects
PostPosted: Thu Jun 23, 2005 7:49 pm 
NHibernate 0.8.3
win2k
.Net 1.1

----
Before I started using lazy loading, I would check for the existence of a relationship via a statement similar to the following:

Code:

if (child.Parent != null)
{
   //I know the Parent exists in db.
   //so I do something with the child.Parent.Id
   //property.
}


However, with lazy-loading, the Parent property is never null (it's an instance of the proxy class), and so my code thinks the Parent object exists, but when accessing the properties of the Parent object, I get an exception.

Is there a way to confirm the actual existence of a proxied object? I'd really like to take advantage of proxies, but I have a slew of nullable many-to-one and one-to-one relationships.

Thanks!
-Tyler Burd


Top
  
 
 Post subject:
PostPosted: Fri Jun 24, 2005 4:38 am 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
With Proxies, the Parent property should also be null if there is no Parent.

The problem with the exception when accessing a property of the Parent indicates that you might have forgotten to make the properties virtual.

_________________
Cuyahoga


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.