The entity enhancer tool for Java Persistence API (JPA) applications in the application server inserts bytecode into an entity class file that allows the JPA provider to manage the state of an entity.
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, there are no containers to manage persistence and you might use this command frequently before packaging application files for testing. After you have created the JPA entities, you can run the wsenhancer tool to inject bytecode into the entities before packaging the JAR file into the EAR file for the application.
The command syntax is as follows:
wsenhancer.sh [parameters][arguments]
wsenhancer [parameters][arguments]
wsenhancer.bat [parameters][arguments]
Issue the command from the bin subdirectory of the app_server_root directory.
In order to use the wsenhancer tool you need entities defined to JPA specifications, and the entities need to be compiled. Run the wsenhancer tool against the entities before packaging them into a JAR file. If the entities are already packaged, you must extract the entity class files, run the enhancer, and recreate the JAR file.
$ cd build /home/user/myproject/build $ ${app_server_root}/bin/wsenhancer.sh
$ cd build /home/user/myproject/build $ ${app_server_root}/bin/wsenhancer
C:\myproject\cd build C:\myproject\build>%app_server_root%\bin\wsenhancer.batAll entities in myproject will be enhanced.
$ cd build /home/user/myproject/build $ ${app_server_root}/bin/wsenhancer.sh Magazine.java
$ cd build /home/user/myproject/build $ ${app_server_root}/bin/wsenhancer Magazine.java
C:\myproject\cd build C:\myproject\build>%app_server_root%\bin\wsenhancer.bat Magazine.javaThe entity, Magazine.java, located in myproject will be enhanced.
For more information about enhancement tools, refer to the section on persistent classes in the Apache OpenJPA reference documentation.