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
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)
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.
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: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.