Java Persistence (JPA) Tutorial With EclipseLink

JPA Tutorial With EclipseLink explains step by step details of setting / configuring Java Persistence (JPA) With EclipseLink And Eclipse

How To Configure EclipseLink (JPA) With Oracle Database?

Java Persistence API (JPA), is a standard interface which wraps different ORM tools such as  Hibernate, EclipseLink, OpenJPA etc. The benefits of using JPA is that you can change the underlying implementation of without changing any code.

ie; you can able to change Hibernate implementation to EclipseLink implementation without changing the code base.

On this standalone JPA Example, we are using Java Persistence (JPA) With EclipseLink

EclipseLink is popular open source ORM (Object Relation Mapping) tool for Java platform, for mapping an entity to a traditional relational database like Oracle, MySQL etc

By using JPA, we can do database operations like Create, Read, Update & Delete etc, with very little code.

Required Libraries

You need to download

  1. JDK 6
  2. Eclipse 3.7
  3. EclipseLink 2.5

Following jar must be in classpath

  1. eclipselink-jpa-modelgen_2.4.1.v20121003-ad44345.jar
  2. classes12.jar
  3. javax.persistence_1.0.0.jar
  4. javax.persistence_2.0.4.v201112161009.jar
  5. org.eclipse.persistence.jpars_2.4.1.v20121003-ad44345.jar
  6. org.eclipse.persistence.jpars.source_2.4.1.v20121003-ad44345.jar

I am creating a sample project that persists Student object (simple POJO (Plain Old Java Object)) into database using JPA

Firstly create a Java Project (File->New->Project), select Java Project and click next, provide name as "JPA2Example" according to following screenshot

Create JPA Project Java Persistence(JPA) With Hibernate


persistence.xml file must be under src/META-INF (Please check below screenshot(project structure)

<persistence xmlns:xsi=""
  version="2.0" xmlns="">
  <persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
      <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver" />
      <property name="javax.persistence.jdbc.url"    value="jdbc:oracle:thin:@" />
      <property name="javax.persistence.jdbc.user" value="username" />
      <property name="javax.persistence.jdbc.password" value="password" />
      <property name="eclipselink.ddl-generation" value="create-tables" />
      <property name="eclipselink.ddl-generation.output-mode" value="database" />


1 2 3 Next

1 Responses to "Java Persistence (JPA) Tutorial With EclipseLink"
  1. Joel Peña 2012-12-10 09:35:16.0

Your email address will not be published. Required fields are marked *