-->
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: Session load vs get
PostPosted: Thu Aug 12, 2004 6:50 pm 
Beginner
Beginner

Joined: Thu Jul 22, 2004 2:15 pm
Posts: 35
When using Hibernate Session, when should I use load and when should I use get. I have been using load, but I always run into the issue when one of my objects with the same id is already loaded into the session. I don't mind getting the Session cached copy.

I think Session.get will fix my problem, but I am not sure when should I use either one. I also understand that get can return a null while load will throw an exception. I am looking for some general guidelines.

TIA

Hibernate version: 2.1.4

Mapping documents: None

Code between sessionFactory.openSession() and session.close():


Person p = new Person();
session.load(p,fomrBean.getPersonID());


Full stack trace of any exception that occurs: NA

Name and version of the database you are using: Mysql 4.1.08

Debug level Hibernate log excerpt:NA

_________________
--------------------------------------------------
To code or not to code... Is that a question?
--------------------------------------------------
Pritpal Dhaliwal


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 13, 2004 2:59 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
RTM Reference Manual Cahpter 9.2

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 13, 2004 4:50 am 
Beginner
Beginner

Joined: Thu Jul 22, 2004 2:15 pm
Posts: 35
thanks.. and I thought I had read the docs ... shame on me..

btw.. why do most examples use load?

_________________
--------------------------------------------------
To code or not to code... Is that a question?
--------------------------------------------------
Pritpal Dhaliwal


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 13, 2004 10:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Because session.load() existed before session.get()


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.