+

Search Tips   |   Advanced Search

wsappid command

The Java Persistence API (JPA) specification supports an entity primary key to be made up of more than one column. In this case, the primary key is called a composite or compound primary key. Provide an ID class, which is specified by the @IdClass annotation, to manage a composite primary key. Use the identity tool for JPA to generate an ID class for entities that use composite primary keys.


Syntax

Before running the command, we must have a copy of the persistence.xml file on the classpath, or specify it as a properties file in the -p [path_to_persistence.xml] argument. Issue the command from the bin subdirectory of the profile_root directory.

The command syntax is as follows:

(UNIX) (ZOS)

wsappid.sh [parameters][arguments]
(iSeries)
wsappid [parameters][arguments]
(Windows)
wsappid.bat [parameters][arguments]


Parameters

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

Each additional argument to the wsappid tool must be one of the following:

The identity tool used with JPA for application server simplifies the task of creating an identity class for entities that use composite IDs. A composite ID is an identity with more than one field as its primary key. The entity class must be compiled, and primary keys must be identified in the entity class. Run the wsappid tool from the command line in the profile_root/bin/ directory. When we run this command, a new class representing the composite ID of the entity is generated. Messages and errors are logged to the console as specified.


Examples

Consider the following entity:

@Entity 
public class Employee { 

@Id 
private int division;  

@Id private int id;  
// . . . 
}
Before the entity is used, an ID class is needed. For this example, assume that the entity is found in the src/main/java directory.

To generate an ID class for the Magazine entity run the following:

(UNIX) (ZOS)

wsappid.sh -s Id src/main/java/Employee.java -d src/main/java
(iSeries)
wsappid -s Id src/main/java/Employee.java -d src/main/java
(Windows)
wsappid.bat -s Id src\main\java\Employee.java -d src\main\java
A new class, EmployeeId.java, is generated in the src/main/java directory.


Additional information

Read the Application identity tool in persistence classes information in the Apache OpenJPA User Guide for more information.

  • Apache OpenJPA User's Guide