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.
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.
- 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.)
- Right click on the Eclipse project that you want to enhance and click on Properties.
- Click on the builders filter, and Create a new Ant builder.
- 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.
- 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".
- 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.
- Click on the "Targets" tab along the top.
- You need to set the enhance target to run as a part of "Manual Build" and "Auto Build" (see screenshot #3 below.)
OpenJPA Plugin for Eclipse
The OpenJPA Eclipse Tooling is a sub-project of the OpenJPA project. It develops IDE tooling for OpenJPA as an Eclipse feature with plug-ins.
Currently it provides an Eclipse Builder for OpenJPA Enhancement.