Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate implements JPA.

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
As the docs say.Hibernate implements JPA 3.0.

so i am having a basic doubt on the above on how to implement this .(knows its a dumb question but please help me as i can't understand)


If i planned to use Hibernate , JPA , EJB3.0 in my application then is the below scenario correct ??

When i submit a form with the fields ,the request is gone to SessionBean of EJB3.0 , which implements all the Hibernate DAO methods , now my question is that do we need do get the Hibernate SessionFactory and Session as the way we obtain a EntityManagerFactory and a EntityManager ??
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use EJB 3, you don't need to use Hibernate, because EJB 3 already includes JPA implementation.
But if you want to use Hibernate, try to search how to change JPA implementation in EJB 3.

But don't use Hibernate interfaces, use JPA interfaces. If your codes use Hibernates interfaces, your codes will not be portable.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kengkaj Sathianpantarit wrote:If you use EJB 3, you don't need to use Hibernate, because EJB 3 already includes JPA implementation.


EJB 3 is a standard, not an implementation, so it can't include a JPA implementation. Its the application server that implements both.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kengkaj ,

Though you were wrong on this "If you use EJB 3, you don't need to use Hibernate, because EJB 3 already includes JPA implementation. "
as Paul said

But you made one valid point " But don't use Hibernate interfaces, use JPA interfaces. If your codes use Hibernates interfaces, your codes will not be portable. "

I want to implement this approach .Do i need to get the Hibernate components from JPA interfaces in a DAO implementation layer only know??

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic