+

Search Tips   |   Advanced Search

wsreversemapping command

The wsreversemapping tool generates persistent class definitions and metadata from a database schema.


Syntax

Before running the command, we must have a copy of the persistence.xml file on the class path, 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)

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


Parameters

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

The wsreversemapping tool is used to perform reverse (bottom-up) mappings of database tables to entity source files. This is useful if developers want to generate Java files from a database for use in other JPA applications. To run this tool:

The generated Java files from the wsreversemapping tool might require some editing before they can be used in an application. Also, generated files do not contain annotations. Annotations can be added manually. Messages and errors are logged to the administrative console as specified by the configuration.


Examples

Generate entities based on the information saved in the schema.xml file. Schema.xml was created by running the schema tool. The Java files are created in the src directory and use the package com.xyz:

(UNIX) (ZOS)

${profile_root}/bin/wsreversemapping.sh -pkg com.xyz -d ./src schema.xml
(iSeries)
${profile_root}/bin/wsreversemapping -pkg com.xyz -d ./src schema.xml
(Windows)
${profile_root}\bin\wsreversemapping.bat -pkg com.xyz -d ./src schema.xml

Generate entities based on information in a DB2 database. Entities are created in the src directory, and use the package com.reversemapped:

(UNIX) (ZOS)

C:\> %profile_root%/bin/wsreversemapping.bat -sa dropDB Magazine.javapkg com.reversemapped -d src 
-connectionDriverName=com.ibm.db2.jcc.DB2Driver -connectionURL=jdbc:db2:localhost:50000/TEST 
-connectionUser=db2User -connectionPassword=db2Password 
(iSeries)
C:\> %profile_root%/bin/wsreversemapping -sa dropDB Magazine.javapkg com.reversemapped -d src 
-connectionDriverName=com.ibm.db2.jcc.DB2Driver -connectionURL=jdbc:db2:localhost:50000/TEST 
-connectionUser=db2User -connectionPassword=db2Password 
(Windows)
C:\> %profile_root%\bin\wsreversemapping.bat -sa dropDB Magazine.javapkg com.reversemapped -d src 
-connectionDriverName=com.ibm.db2.jcc.DB2Driver -connectionURL=jdbc:db2:localhost:50000/TEST 
-connectionUser=db2User -connectionPassword=db2Password 


Additional information

For more information, read the mapping section in the Apache OpenJPA User Guide.

  • Apache OpenJPA User's Guide