aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate suppourt with JPA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate suppourt with JPA" Watch "Hibernate suppourt with JPA" New topic
Author

Hibernate suppourt with JPA

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi

I am trying to create a my first simple example in JPA .

But to my surprise JPA itself is asking for an option of which ORM tool (I mean Toplink , Hibernate , ---etc)

Please tell me i dont understand this :

What is the purpose of using JPA rather than directly using Hibernate .


Save India From Corruption - Anna Hazare.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

JPA is a specification. Hibernate is one of a few implementations of that specification.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you very much Paul , still i am having some queries n this .

But in the examples of JPA , i , dont see Hibernate is not being used anywhere but directly EntityManager methods to perform CRUD operations .

Then please let me know where exactly actually Hibernate is being used in JPA (Because all the things are performed directly by EntityManager ) .
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3825

Ravi Kiran V wrote:But in the examples of JPA , i , dont see Hibernate is not being used anywhere but directly EntityManager methods to perform CRUD operations .
Then please let me know where exactly actually Hibernate is being used in JPA (Because all the things are performed directly by EntityManager ) .

EntityManager is the heart of manipulating Entities in JPA. Hibernate provides the implementation through Hibernate Entity Manager


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you Vijitha ,

But i am directly using EntityManager.persist() method .

So my question is where exactly Hibernate is being used ??

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

As Vijitha says, it is being used as a JPA implementation.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Still i don't understand

There is a JPQL and not also HQL .

so actually where ??

Please provide me any link also would be okay .
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Ravi:

There is a book titled Java Persistence with Hibernate which you would find useful.

John.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


But i am directly using EntityManager.persist() method .

So my question is where exactly Hibernate is being used ??

javax.persistence.EntityManager is an interface. Hibernate provides an implemention of that interface.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Paul thanks for replying .

Ya i know that

For JPA as there is EntityManager for Hibernate there is Session

and Session is also an interface .

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Indeed. What's your point?
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Means what i think is as in case of JDBC .There is a Driver interface and the different vendors provided their own implementation class .

But EntityManager is a interface and Hibernate Session is also a interface know .



Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3825

Ravi Kiran V wrote:Means what i think is as in case of JDBC .There is a Driver interface and the different vendors provided their own implementation class .
But EntityManager is a interface and Hibernate Session is also a interface know .

Hibernate is a persistence framework on its own, you can use Hibernate directly for your persistence needs. But JPA (introduced later) is the standardization for the persistence which Hibernate provide an implementation through "Hibernate Entity Manager".
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you for your suppourt

The question what i am asking is

"Can't i use the JPA directly ""?? for providing persistence
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3825

Ravi Kiran V wrote:.. Can't i use the JPA directly ""?? for providing persistence

You should understand that JPA is a standardized specification for the persistence. Different vendors (Hibernate being one of them as pointed out earlier) provide implementations you can choose which to use. Of course you don't have to change your code as you are coding to a standardized specification (that is JPA).
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

That makes sense .Thank you Vijitha .
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hibernate suppourt with JPA