+

Search Tips   |   Advanced Search

eclenhancer command

The entity enhancer tool for Java Persistence API (JPA) applications inserts bytecode into an entity class file that supports the JPA provider to manage the state of an entity. Use this command-line tool to enhance entities under the Java Persistence API (JPA) 2.1 specification provider, EclipseLink, for WebSphere Application Server.

JPA with the application server requires that all entity classes be enhanced to manage their state. In a container-managed environment, automated enhancement is provided by the containers. In a Java SE environment, though, no containers manage persistence and we might use this command frequently before packaging application files for testing. After creating the JPA entities, we can run the eclenhancer tool to inject bytecode into the entities before you package the JAR file into the EAR file for the application.


Syntax

Before we run the command, we must have a persistence.xml file in the class path, or specify its location in the -persistenceinfo argument. Issue the command from the bin subdirectory of the profile_root directory.

The command syntax is as follows:

(UNIX) (ZOS)

eclenhancer.sh [arguments] <source> <target>
(Windows)
eclenhancer.bat [arguments] <source> <target>


Parameters

The enhancer accepts the standard set of command-line arguments defined by the configuration framework along with the following required arguments:

If the directory does not match the enhanced class package, the package structure is created beneath the directory. By default, the enhancer overwrites the original .class file.

To use the eclenhancer tool, define entities to the JPA specifications, and we must compile the entities. We can run the eclenhancer tool against the entities before you package them into a JAR file. If the entities are already packaged, we can extract the entity class files, run the enhancer, and re-create the JAR file.

To enhance your entities:

Messages and errors are logged to the administrative console as specified in the log settings. After we start the eclenhancer command, the files are enhanced.


Examples

To enhance entities located in a JAR:

(UNIX) (ZOS)

$ cd build
/home/user/myproject/build $ ${profile_root}/bin/eclenhancer.sh -persistenceinfo
/home/user/myproject/build/myjar-containing-persistencexml.jar -classpath 
/classpath1;/classpath2 /home/user/myproject/build/myjar-source.jar 
/home/user/myproject/build/myjar-target.jar
(Windows)
C:\myproject\build>%profile_root%\bin\eclenhancer.bat -persistenceinfo c:\myjar-
containing-persistencexml.jar -classpath c:\classpath1;c:\classpath2 c:\myjar-
source.jar c:\myjar-target.jar

  • Developing JPA 2.x applications for a Java EE environment
  • Developing JPA 2.x applications for a Java SE environment
  • EclipseLink Static Weaving