-->
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.  [ 4 posts ] 
Author Message
 Post subject: Find versus Load
PostPosted: Thu Jan 19, 2006 6:42 pm 
Newbie

Joined: Sun Jan 15, 2006 8:29 pm
Posts: 5
Hi,

I am using Hibernate 3 and have run into the following situation

When I use Load...I find the record I am looking for:

NodeAlias aNodeAlias = NodeAliasDAO.getInstance().load(new Integer(anodeid));

When I run the exact same test case with find, I get an error:

NodeDateType aNodeDateType = (NodeDateType)NodeDateTypeDAO.getInstance().find("from NodeDateType NA WHERE NA.IDNode = " + anodeid).get(0);


NULL is returned in the second case.

Does anyone have an idea why this is happening?


thanks,
Minh


Top
 Profile  
 
 Post subject: Re: Find versus Load
PostPosted: Thu Jan 19, 2006 9:42 pm 
Newbie

Joined: Thu Jan 19, 2006 9:36 pm
Posts: 1
Location: Oslo, Norway
Minh Triet Nguyen wrote:
Hi,

NULL is returned in the second case.

Does anyone have an idea why this is happening?


thanks,
Minh


Remember that load() will return a proxy instead of a persisted instance. So in the first case, if aNodeAlias != NULL, it doesn't mean that the object exists. An exception will first be thrown when the proxy is later accessed, if no object was found.

Werner


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 19, 2006 11:15 pm 
Regular
Regular

Joined: Tue Dec 14, 2004 5:21 am
Posts: 104
Location: india
use of find is not recommended since it is depricated in hibernate 3 . better go for session.createQuery()

_________________
sHeRiN
thanks for your ratings ...... :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 12:37 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Does the fact that you're looking up a NodeAlias in one query, and NodeDateType in the other, not have something to do with it? Different tables, etc.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.