OpenJPA Logo   ASF Logo

Enhancing Entities with Eclipse

If you are using Eclipse to write and deploy your application, then you have two choices for build time enhancement of your entities. But, if you're using orm.xml to map the Entities, then you can only use the Custom ANT Builder method below, as the OpenJPA Plugin for Eclipse currently does not handle that scenario.

OpenJPA Plugin for Eclipse

Pinaki Poddar has created an initial Eclipse Plug-in for OpenJPA 1.2, which can be used to enhance your entities during the normal Eclipse builder steps. Details about how to install and use the plugin can be found at http://people.apache.org/~ppoddar/eclipse/index.html

Please note, that the above plugin has not been officially accepted into a OpenJPA branch or released by the OpenJPA project, but please give it a try and send any feedback to users@openjpa.apache.org

Custom ANT Builder

For steps documented below, I have the following directory structure. Note, these steps must be followed for each project that has Entities that need to be enhanced.

/builder_project
    enhance.xml <- the OpenJPA builder....
/bin <- Compile directory
/src <- Source directory
/jpa_lib <- OpenJPA binary and all jars from the lib dir of the binary download
    commons-collections-3.2.jar
    commons-lang-2.1.jar
    commons-pool-1.3.jar
    derby-10.2.2.0.jar
    geronimo-jpa_2.0_spec-1.0-EA-SNAPSHOT.jar
    geronimo-jta_1.1_spec-1.1.1.jar
    openjpa-2.0.0-SNAPSHOT.jar
    serp-1.13.1.jar
/lib <- other libs
  1. After you add the enhance.xml file to your file system, make sure to refresh your Eclipse workspace so it knows about the newly added file. Make sure that the enhance.xml file is listed in the Navigator view (screenshot #1 below.)
  2. Right click on the Eclipse project that you want to enhance and click on Properties.
  3. Click on the builders filter, and Create a new Ant builder.
  4. Name your builder, then click on "Browse Workspace" in the buildfile box. If you downloaded the enhance.xml file and refreshed your workspace, it should be listed there. If not, go back to step 1 and make sure that Eclipse detects your enhance.xml file.
  5. In the "Base Directory" box, click on the variables button and select build_project. This should refer to the root of your project. In the directory structure above, it refers to "builder_project".
  6. In the "Arguments" box you need to add the following properties -Dopenjpa.libs and -Dbuild.dir (see screenshot #2 below.) The -Dopenjpa.libs is the path to the OpenJPA libs, relative to the root of the project. The -Dbuild.dir is the path to the build directory, relative to the root of the project. In the directory structure above, openjpa.libs should be set to jpa_lib and build.dir should be set to bin.
  7. Click on the "Targets" tab along the top.
  8. You need to set the enhance target to run as a part of "Manual Build" and "Auto Build" (see screenshot #3 below.)

Copyright (C) 2005-2009 Apache Software Foundation. Licensed under Apache License 2.0.
Apache, the Apache feather logo and OpenJPA are trademarks of Apache Software Foundation.