The wsreversemapping tool generates persistent class definitions and metadata from a database schema.
Before running the command, you 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:
wsreversemapping [parameters][arguments]
Each element of the list must follow the naming conventions for the openjpa.jdbc.Schemas property. If this parameter flag is omitted, it defaults to the value of the Schemas property. If the Schemas property is not defined, then all schemas are reverse mapped.
If no package name is given, the generated code does not contain package declarations.
If the path does not match the package of a class, the package structure is created beneath this directory. This parameter defaults to the current directory.
This method can be useful when dealing with multiple schemas that have tables with identical names.
By default, relation field names are derived from the name of the related class.
Set this parameter flag to true to generate primitive wrapper fields instead for columns that support null values.
Set this parameter flag to true to map them to Object fields instead.
If your schema has primary keys on many join tables as well, set this flag to true to avoid creating classes for those tables.
Typically, the tool uses application identity for all generated classes.
This forces the tool to create custom application identity classes even when there is only one primary key column.
The default setting is false.
The default suffix is Id.
The format is SQLTYPE1=JavaClass1, SQLTYPE2=JavaClass2. The SQL type name first looks for a customization that is based on SQLTYPE(SIZE,PRECISION), then SQLTYPE(SIZE), and then SQLTYPE. If a column with type CHAR is found, it first looks for the CHAR(50,0) type name specification, then it looks for the CHAR(50), and finally for the CHAR. For example, to generate a char array for every char column whose size is exactly 50 characters, and to generate a short for every type name of INTEGER, you might specify, CHAR(50)=char[],INTEGER=short.
If you do not specify a reverse customizer of your own, the system defaults to a PropertiesReverseCustomizer. This customizer supports specifying simple customization options in the properties file given with the -customizerProperties flag.
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:
${profile_root}/bin/wsreversemapping -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:
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
For more information, read the mapping section in the Apache OpenJPA User Guide.