• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

difference between session and entitymanager

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

guys i am using session and entitymanager, but i can not tell the difference between them

some one please explains to me little bit
 
Ranch Hand
Posts: 265
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jim,

If you're talking about Hibernate, then the EntityManager and the Hibernate Session are are equivalent. You use the EntityManager if you want to use the Java Persistence API, and Hibernate's Session if you're using Hibernate's API.
 
jim li
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for you help

but i still have one question:

is the entitymanager used to interact with the JEB3?

but the session does not?
 
Stevi Deter
Ranch Hand
Posts: 265
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB3 is a pluggable architecture, so you need to be clear on what element you mean.

EntityManager is the Hibernate JPA (Java Persitence API) implementation. If you want to use the JPA instead of Hibernate's Core, then use EntityManager.

Hibernate Annotations implement the JPA annotations, plus have additional annotations for Hibernate specific features.
 
ranger
Posts: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you will also see, is that Hibernate is just wrapping their Session object in their EntityManager implementation. Which is why you can always get a Session object from your EntityManager, is you want to go to the Session api.

Mark
 
jim li
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for you help

i believe that it is what i want to know

so based on what you said

entitymanager should be more powerful than session

since session is wrapped in entitymanager implementation, so entitymanager has everything session has, and owns some extra stuff.

am i correct?
 
Mark Spritzler
ranger
Posts: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by jim li:
thank you for you help

i believe that it is what i want to know

so based on what you said

entitymanager should be more powerful than session

since session is wrapped in entitymanager implementation, so entitymanager has everything session has, and owns some extra stuff.

am i correct?



Actually the complete opposite.

Session has more stuff to it, the EntityManager is a specification api, and the spec doesn't cover everything that Hibernate can do, so only certain methods of a Session object is called, not all of them.

Mark
 
jim li
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You! Finally a post which explains the difference between Entity Manager and Hibernate Session (org.hibernate.Session).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!