• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes.
I need what are the best and why ?
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
session.get is clearly the best.

It requires typing in the fewest letters.

-Cameron McKenzie
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!