Object-Relational Mappings: Configuring the Persistence Provider for JPA Projects

This document describes the following:


1. Configuring a JPA Project to Use EclipseLink Persistence Provider

EclipseLink is an open source persistence provider contributed to Eclipse by Oracle.

OEPE provides an EclipseLink project facet that you can use in your Eclipse JPA project. When selected, the following happens:

  • the project build path is automatically configured to include EclipseLink persistence provider JAR files shipped with Oracle WebLogic Server 11gR1.
    Note that, even though the library files are not shipped with earlier version of Oracle WebLogic Server, you can download them using the facet configuration wizard.

  • the database connection properties specific to EclipseLink can be automatically configured in the persistence.xml file of your Eclipse JPA project.

Oracle WebLogic Server releases prior to 11gR1, as well as third-party J2EE application servers, support EclipseLink persistence provider through the user library provider mechanism. For more information, see Oracle WebLogic Server Support for Persistence Provider Libraries and Deployment.

To configure your Eclipse JPA project to use EclipseLink as a persistence provider, use one of the following options:

  1. Automatically configure your JPA project to use EclispeLink persistence provider shipped with Oracle WebLogic Server 11gR1, as follows:
    • When creating a new JPA project, select Oracle WebLogic Server 11gR1 as your target runtime.

    • Click Modify... in the Configuration portion on the New JPA Project > JPA Project dialog. This will open the Project Facets dialog.

    • Select Java Persistence Library (EclipseLink) from the Project Facet list, and then click OK to apply your selection and close the Project Facets dialog.

    • Click Next on the New JPA Project > JPA Project dialog.

    • On the next, JPA Facet screen of the New JPA Project dialog, select EclipseLink as the platform for your project.

    • Specify the database connection in the Connection field.

    • In the JPA implementation portion of the New JPA Project dialog, select Use implementation provided by server runtime, and then click Next, as Figure 1 shows.



      Figure 1.
      Configuring User Libraries


      This will display the New JPA Project > EclipseLink screen, as Figure 2 shows.



      Figure 2.
      Automatically Configuring User Libraries


    • Select EclipseLink VersionNumber, and then click Finish. Note that if the EclipseLink library is not listed, you need to click Download library. If your machine is located inside of a network, which requires a proxy to access outside resource such as the Internet, the download may fail due to the fact that Eclipse IDE includes a Web browser to let you access the Internet from within the IDE. In this case, reconfigure your Eclipse IDE proxy settings using Window > Preferences > General > Network Connections, and try again.

    If you expand your JPA project node in the Project Explorer, and then expand the EclipseLink node, you will find the EclipseLink persistence provider library, as well as Java persistence library, as Figure 3 shows.



    Figure 3.
    Persistence Libraries


  2. The persistence.xml file of your JPA project now contains EclipseLink persistence provider settings, as Figure 4 shows.



    Figure 4.
    persistence.xml File


  3. Manually configure a Java user library which includes the EclipseLink JAR files that you downloaded separately, as follows:

    • When creating a new JPA project, select Oracle WebLogic Server 11gR1 as your target runtime.

    • Click Modify... in the Configuration portion on the New JPA Project > JPA Project dialog. This will open the Project Facets dialog, as Figure 5 shows.



      Figure 5.
      Project Facets Dialog


    • Select Java Persistence Library (EclipseLink) from the Project Facet list, and then click OK to apply your selection and close the Project Facets dialog.

    • Click Next on the New JPA Project > JPA Project dialog.

    • On the next, JPA Facet screen of the New JPA Project dialog, select EclipseLink as the platform for your project, and then specify the database connection in the Connection field.

    • In the JPA implementation portion of the New JPA Project > JPA Facet dialog, leave the default selection of Use implementation provided by server runtime, and then click Next. This will display the New JPA Project > EclipseLink screen. Click Download library. This will open Download Library dialog. Select the EclipseLink library you would like to use, and click Next. Note that if your machine is located inside of a network, which requires a proxy to access outside resource such as the Internet, the download may fail due to the fact that Eclipse IDE includes a Web browser to let you access the Internet from within the IDE. In this case, reconfigure your Eclipse IDE proxy settings using Window > Preferences > General > Network Connections, and try again.

    • Add the EclipseLink library to your Eclipse JPA project's build path.



    2. Configuring a JPA Project to Use Kodo Persistence Provider

    Oracle Kodo is the default persistence provider for Oracle WebLogic Server 10n. OEPE enables automatic configuration and deployment of Eclipse JPA projects that use Kodo as their persistence provider on Oracle WebLogic Server.

    OEPE provides Oracle Kodo facet that allows you to configure your JPA project to use Oracle Kodo as the persistence provider. When selected, the following happens:

    • the project build path is automatically configured to include Oracle Kodo persistence provider JAR files shipped with Oracle WebLogic Server;

    • the database connection properties specific to Oracle Kodo can be automatically configured in the persistence.xml file of your Eclipse JPA project.

    Note that earlier versions of Kodo require a build-time class enhancement process. OEPE triggers execution of a Kodo-specific class enhancer on your Kodo JPA project when deployed to Oracle WebLogic Server 10.0. For more information, see Oracle WebLogic Server Support for Persistence Provider Libraries and Deployment.

    To configure your Eclipse JPA project to use Oracle Kodo as a persistence provider, follow this procedure:

    • When creating a new JPA project, or configuring a Web project or utility with a JPA facet, click Modify... in the Configuration portion on the New JPA Project > JPA Project dialog. This will open the Project Facets dialog, as Figure 6 shows.



      Figure 6.
      Project Facets Dialog


    • Select WebLogic Utility Module Extensions and Java Persistence Library (Oracle Kodo) from the Project Facet list, and then click OK to apply your selection and close the Project Facets dialog.

    • Click Next on the New JPA Project > JPA Project dialog.

    • On the next, New JPA Project > JPA Facet screen of the New JPA Project dialog, select Generic as the platform for your project.

    • Specify the database connection in the Connection field, and then click Next. This will display the New JPA Project > Kodo screen. Select Weblogic System Library (Oracle Kodo 4.2) from the Library > Type combo box, as Figure 7 shows.



      Figure 7.
      New JPA Project - Kodo Dialog


    • Click Finish.

    If you expand your JPA project node in the Project Explorer, and then expand the WebLogic System Libraries node, you will find the Oracle Kodo persistence provider library, as well as Java persistence library, at the end of the list, as Figure 8 shows.



    Figure 8.
    Persistence Libraries


    The persistence.xml file of your JPA project now contains Oracle Kodo persistence provider settings, as Figure 9 shows.



    Figure 9.
    persistence.xml File




  4. 3. Oracle WebLogic Server Support for Persistence Provider Libraries and Deployment

    Oracle WebLogic Server supports EclipseLink and Oracle Kodo persistence providers.

    The following table maps versions of Oracle WebLogic Server and the supported persistence libraries:


    Oracle WebLogic Server Version EclipseLink JPA Oracle Kodo JPA
    11g Release 1 Patch Set 1 (10.3.2) - Oracle WebLogic Server system library (Oracle TopLink 11g Release 1 Patch Set 1)
    - EclipseLink 1.0 downloadable library
    - EclipseLink 1.0.1 downloadable library
    - EclipseLink 1.0.2 downloadable library
    - EclipseLink 1.1 downloadable library
    - Oracle WebLogic Server system library (Oracle Kodo 4.2)
    11g Release 1 (10.3.1) - Oracle WebLogic Server system library (Oracle TopLink 11g Release 1)
    - EclipseLink 1.0 downloadable library
    - EclipseLink 1.0.1 downloadable library
    - EclipseLink 1.0.2 downloadable library
    - EclipseLink 1.1 downloadable library
    - Oracle WebLogic Server system library (Oracle Kodo 4.2)
    10g Release 3 (10.3) - EclipseLink 1.0 downloadable library
    - EclipseLink 1.0.1 downloadable library
    - EclipseLink 1.0.2 downloadable library
    - EclipseLink 1.1 downloadable library
    - Oracle WebLogic Server system library (Oracle Kodo 4.2)
    10.0 - EclipseLink 1.0 downloadable library
    - EclipseLink 1.0.1 downloadable library
    - EclipseLink 1.0.2 downloadable library
    - EclipseLink 1.1 downloadable library
    - Oracle WebLogic Server system library (Oracle Kodo 4.2)

    Note: Provides enhancement of persistent classes at publish time
    9.2 - EclipseLink 1.0 downloadable library
    - EclipseLink 1.0.1 downloadable library
    - EclipseLink 1.0.2 downloadable library
    - EclipseLink 1.1 downloadable library
       




    4. Related Information

    Getting Started With the Oracle Database Plugin for Eclipse

    EclipseLink User's Guide - Developing JPA Projects