Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: lots more content, based on Rick Curtis' blog entries

Excerpt
hiddentrue

How to enhance entity classes from Maven2

There is a sandbox plugin to enhance with Maven available at http://mojo.codehaus.org/openjpa-maven-plugin/usage.html.

Alternately, enhancement can be performed by using the antrun plugin to launch the command-line enhancement tool on your classes:

...

What is Enhancement Anyway?

The JPA spec requires some type of monitoring of Entity objects, but the spec does not define how to implement this monitoring. Some JPA providers auto-generate new subclasses or proxy objects that front the user's Entity objects at runtime, while others use byte-code weaving technologies to enhance the actual Entity class objects at build time. OpenJPA supports both methods, but strongly suggests only using the build time enhancement.

Build Time Enhancement

Build time enhancement is the recommended method to use with OpenJPA, as it it the fastest and most reliable method. Please follow the links below based on your development environment:

Runtime Enhancement

When running in a Java SE environment or in a non-Java EE 5 compliant container, OpenJPA defaults to using runtime subclassing enhancement. The subclassing enhancement support was added originally as a convenience to new developers to reduce the amount of work to get a 'HelloWorld-ish' OpenJPA application working out of the box. It was never meant to run in production. So you're probably thinking that this sounds great! OpenJPA handles enhancement automatically for me and I can stop reading this post. Wrong! Subclassing has two major drawbacks. First off, it isn't nearly as fast as byte-code enhancement and the second drawback is that there are some documented functional problems when using the subclassing support. The moral of the story is, don't use this method of enhancement.

If you really want to use runtime enhancement, the following Runtime Enhancement page describes how to use the -javaagent setting in ANT and Eclipse projects.

Additional information regarding the subclassing enhancement can be found in the OpenJPA docs.

Author Attribution

The content for this page and sub-pages was adapted from content created by OpenJPA contributor Rick Curtis from the following WebSphere and Java Persistence blog entries:
http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html
http://webspherepersistence.blogspot.com/2009/04/openjpa-enhancement-eclipse-builder.html