permaculture playing cards
The moose likes Object Relational Mapping and the fly likes EJB3 JPA implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "EJB3 JPA implementation" Watch "EJB3 JPA implementation" New topic

EJB3 JPA implementation

Tejas Jain
Ranch Hand

Joined: Mar 04, 2008
Posts: 119
I got an ejb3-persistence.jar (52KB) from Hibernate site.
If I only want to use JPA specific API to create a DB access layer, is this jar enough? Do I have to use it with other hibernate jar files?

Is JPA a complete and self-sufficient API (like EJB2.x API) to access DB?

"Knowing is not enough, you must apply... Willing is not enough, you must do."
--Bruce Lee
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

To use JPA you'll need an API that implements it, like Hibernate. To use JPA with Hibernate you'll need the following JAR files (I could be off by one or 2)

hibernate-annotations (if using annotations)
hibernate-commons-annotations (if using annotations)

Yea, I think that's all.
[ April 23, 2008: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Looks like you're going to be using Hibernate with that ejb3-persistence.jar file of yours.

Gregg is correct, if you want to use JPA, you need a framework that supports it. Here's what you need to support a basic JPA & Hibernate development environment:

* A JDBC compliant Database. (and the ability to perform the most basic of database administration tasks.)
* The JDK 1.5 or better, as annotations didn't exist before Java 5
* JDBC Drivers for your Database -that's how Hibernate connects to your database of choice
* The various jar files and libraries associated with the Hibernate Core and Hibernate Annotations (essentially, you need Hibernate)
* A properly configured hibernate.cfg.xml file on your runtime classpath.

My website has a free tutorial that goes through all of the steps required to set up a JPA and Hibernate environment.

How to Set Up a Hibernate and JPA (Java Persistence API) Environment on Windows

I even go through the installation in this free youtube video.

CBT Video Tutorial on Setting Up a JPA Environment with MySQL & the JDK

Hope that all helps!

-Cameron McKenzie
[ April 23, 2008: Message edited by: Cameron Wallace McKenzie ]
John King
Ranch Hand

Joined: Aug 27, 2002
Posts: 165
ejb3-persistence.jar contains only one class (Persistence), four interfaces, several exceptions, and many annotations. It does not have much implementations, and is completely different from EJB2.x API.
Sun has the copyright for the code in ejb3-persistence.jar. JBoss put it in this jar file.

I used Hibernate alone with hibernate3.jar (with some commons jars) before.
It worked fine. We can say JPA is built on top of Hibernate (or Toplink, ...) and JPA API itself is not enough to create a DB access layer.

If your implementation is based on Hibernate EJB3 JPA, your code is not portable to other EJB3 JPA implementations (e.g., Toplink...)
[ April 23, 2008: Message edited by: John King ]
I agree. Here's the link:
subject: EJB3 JPA implementation
It's not a secret anymore!