File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes query.uniqueResult() or session.get or session.load() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "query.uniqueResult() or session.get or session.load()" Watch "query.uniqueResult() or session.get or session.load()" New topic
Author

query.uniqueResult() or session.get or session.load()

Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
i read that if we need to get instance from database which we know primary key we can use these three ways

1)query.uniqueResult()
2)session.get
3)session.load()
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16356

Samanthi perera wrote:i read that if we need to get instance from database which we know primary key we can use these three ways

1)query.uniqueResult()
2)session.get
3)session.load()


Yep that is true. Do you have a question?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
yes.
I need what are the best and why ?
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4932

session.get is clearly the best.

It requires typing in the fewest letters.

-Cameron McKenzie


Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
 
 
subject: query.uniqueResult() or session.get or session.load()
 
developer file tools