-->
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.  [ 5 posts ] 
Author Message
 Post subject: Is there any different between session.load and session.get?
PostPosted: Thu Sep 09, 2004 4:58 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Hi everyone:

We know the Session Object have a "get" method and a "load" method. They are
Code:
session.get(Class,id); session.load(Class,id);
They both get an single object from database.

I think the two method is useful if I want to get one object one time.
But I also want to know the difference between them.

I mean that is there any difference between the two method? THks!

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 5:18 am 
Beginner
Beginner

Joined: Tue Jan 27, 2004 8:25 am
Posts: 45
As far as I know, load() throws an exception if the object is not found, and get() returns null.


Top
 Profile  
 
 Post subject: Thks
PostPosted: Thu Sep 09, 2004 5:53 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Thank you. I think the "load" method is not more useful than the "get" method. :-)

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 8:16 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
get:
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance, or a proxy for the instance, is already associated with the session, return that instance or proxy.)

load:
Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.
You should not use this method to determine if an instance exists (use find() instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.

better use get

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: Thks
PostPosted: Thu Sep 09, 2004 7:32 pm 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Thank you. I will use "get" more. :-)

_________________
You are not alone...


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