The moose likes Object Relational Mapping and the fly likes Load and Get Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Load and Get" Watch "Load and Get" New topic
Author

Load and Get

Sangeetha deshpande
Greenhorn

Joined: May 02, 2007
Posts: 1
whats the diffrence between load and get?


Thanks in advance
Sangeetha
Jaikiran Pai
Saloon Keeper

Joined: Jul 20, 2005
Posts: 6718

As per the javadoc of Session-

"load" method:

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.


whereas "get" method:

Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.


So, load is going to throw an error if the object for a given id does not exist whereas get is just going to return null, in such a case.


[My Blog] [JavaRanch Journal]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16622

I think get will also be returning a proxy object. whereas load wanted to load the data, and that is one of the reasons why it needs to throw an exception.

Or it could be the other way around.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
IntelliJ Java IDE
 
subject: Load and Get
 
Threads others viewed
JQuery: Problem with $(this).find('input'). serialize()
load() vs get()
how to get the bytes required to load a file in memory?
Do you know a good Connection pooling utility
how to get the bytes required to load a file in memory?
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com