IntelliJ Java IDE
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: 16624

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: 4962

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()
 
Threads others viewed
error: no session or session was closed
Regarding session.load()
Session
how to check record in db table before inserting data, whether that is available or needs to be inse
hibernate locking strategies
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture