• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session

 
sarah Marsh
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm new to Hibernate. What's difference between Session.get and Session.load?

Thanks!
 
Scott Selikoff
author
Saloon Keeper
Posts: 4031
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you read this article?. Also, from the API on load:

"You should not use [load] to determine if an instance exists (use get() instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error."
[ September 30, 2008: Message edited by: Scott Selikoff ]
 
Onkar Joshi
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The interesting bit : load() may give you only a proxy with just the id loaded instead of the real entity. When working with collections, this can be particularly efficient in some cases since Hibernate may need only the id of the entity to be added as a foreign key. So effectively, you may be able to avoid doing a SELECT for that entity.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic