File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes JPA implementation ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JPA implementation ?" Watch "JPA implementation ?" New topic
Author

JPA implementation ?

Mishaal Khan
Ranch Hand

Joined: Aug 21, 2008
Posts: 61
Hi,

I am little confused about JPA services and its implementation. In EJB3 in Action , it says JPA standardizes the
ORM framework so that you can run your code with any persistence provider.I am not clear yet that :

1) does JPA not provide implemention for its services i.e EntityManager and cannot be used without persistence provider
i.e (Hibernate or Toplink) ?

2) It also says JPA can be used without container ,so it means if we are using container or app server for example
jboss , then hibernate jars are already included in jboss and we need not to include hibernate jars in classpath ?

3) If we are using JPA without container i.e in a desktop application,then we need to include hibernate jars in classpath
to get the persistence privider or get the implementation of JPA ?

Please clearify.

Thanks.


Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1280

Hi Mishaal,

JPA is basically only the standardized specification for O/R mapping in Java. It also defines the necessary interfaces, annotations, XML descriptors etc. you need to use JPA. But it doesn't offer an implementation for JPA. Additionally you need a provider like Hibernate, Toplink or EclipseLink.

If you use a compliant JEE container it must provide some implementation of JPA / JPA 2. The specific implementation may vary from container to container. But at runtime you should have all needed libraries or JARs already in place.

If you use JPA in a standalone application you have to provided the needed JARs for the JPA interfaces and an implementation, i.e. the provider. There are different bundles available which often contain the necessary JARs for JPA interfaces etc. and the JARs for the provider itself. Additionally there are some limitations like container-managed transaction which are obviously not available when using JPA outside a container.

Marco
Mishaal Khan
Ranch Hand

Joined: Aug 21, 2008
Posts: 61
Thanks for your reply Marco.

As you mentioned we always need to include required jars in classpath , but I am confused
that I tried a jpa tutorial from laliluna website which is using jboss and I did not include the hibernate jar files in classpath
and the application works fine without those jars ,how come ?

Thanks in advance.
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1280

I think you got me wrong.

If you create a JEE (= enterprise) application which runs inside an application server (= JBoss) you do NOT need to provided additional JARs. Because JBoss 5.x is EE compliant it already provides some provider for the JPA.

Marco
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Actually, he said when you run your application in a JEE container (like JBoss AS for example), the container is required to provide a JPA implementation, which includes all the necessary Jars, etc. This is what you're seeing.
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1280

Thanks Mark
Mishaal Khan
Ranch Hand

Joined: Aug 21, 2008
Posts: 61
Thanks both of you ,thats all I wanted to confirm !

Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Marco Ehrentreich wrote:Thanks Mark

Yes, sorry. I had already posted my comment when I saw yours
 
 
subject: JPA implementation ?
 
Similar Threads
Application-Managed Transaction without joining
Where is the JPA source code (in JBoss 4.2)?
Which one is better between EntityManager and getHibernateTemplate()?
JPA without container?
EJB vs. Hibernate