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 if you want 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 you might use this command frequently before packaging application files for testing. After you create the JPA entities, you can run the eclenhancer tool to inject bytecode into the entities before you package the Java archive (JAR) file into the enterprise archive (EAR) file for the application.
Syntax
Before you run the command, you 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:
![[AIX]](../images/aixlogo.gif)
![[HP-UX]](../images/hpux.gif)
![[Linux]](../images/linux.gif)
![[Solaris]](../images/solaris.gif)
![[z/OS]](../images/ngzos.gif)
eclenhancer.sh [arguments] <source> <target>
![[Windows]](../images/windows.gif)
eclenhancer.bat [arguments] <source> <target>
Parameters
- classpath <path>: Specifies the location of the Java source files to weave: either a directory or a JAR file. If the persistence.xml file is not in this location, you must use the -persistenceinfo attribute to specify the location of the persistence.xml.
- <source>: Specifies the location of the Java source files to weave: either a directory or a JAR file. If the persistence.xml file is not in this location, you must specify the location of the persistence.xml using the -persistenceinfo attribute.
- <target>: Specifies the output location: either a directory or a JAR file.
Usage
To use the eclenhancer tool, you need to define entities to the JPA specifications, and you must compile the entities. You can run the eclenhancer tool against the entities before you package them into a JAR file. If the entities are already packaged, you can extract the entity class files, run the enhancer, and re-create the JAR file.
- Verify that your entities are in the class path. Add them if they are not in the class path.
- Run the eclenhancer command. It is found in profile_root/bin directory.
Examples
To enhance entities that are located in a JAR:
![[AIX]](../images/aixlogo.gif)
![[HP-UX]](../images/hpux.gif)
![[Linux]](../images/linux.gif)
![[Solaris]](../images/solaris.gif)
![[z/OS]](../images/ngzos.gif)
$ 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]](../images/windows.gif)
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