The wsmapping tool is used to provide top-down mapping of the entity object model to the database relational model. You can use the wsmapping tool to create database tables.
Before running the command, you must have a copy of persistence.xml 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:
wsmapping.sh [options][arguments]
wsmapping [options][arguments]
wsmapping.bat [options][arguments]
These options correspond to the actions of the schema tool. Add is the default action if none is specified. Actions can be composed in a list separated by commas.
The XML document can then be modified, manipulated and committed to the database with the schema tool.
Combine this parameter with a schemaAction of build to generate a script that recreates the schema for the current mappings, even if the schema exists.
The default is true.
The default is true.
Certain OpenJPA components use these tables and sequences, such as the table schema factory. When using other actions, the openjpaTables parameter controls whether these tables can be dropped or not. The default setting is false.
The default is set to false.
This is the equivalent to setting the openjpa.jdbc.Schemas property to run once. This parameter corresponds to the -schemas/-s parameter in the wsschema tool. This option is ignored if -readSchema/-rs is not set to true.
Reading the existing schema ensures that OpenJPA does not generate any mappings that use the table, index, primary key or foreign key names that conflict with existing names.
The default is true.
The default is true. This means that to add a new foreign key to a class that has already been mapped, you must explicitly set this parameter flag to true.
The default is true. This means that to add new indexes to a class that has already been mapped, you must explicitly set this parameter flag to true.
The default is true.
If you do not supply any arguments to the wsmapping tool, it runs on the classes in the persistent classes list.
Before running the wsmapping tool, you must configure the data source information, including the URL, user, and password. It is required that the wsenhancer tool is run before the wsmapping tool to insert bytecode into the entity classes. Also, the compiled class files for your entities should be on the class path. Assume that entity class files can be found in target/classes, for example:
export CLASSPATH=${CLASSPATH}:target/classes
wsmapping.sh ...
export CLASSPATH=${CLASSPATH}:target/classes
wsmapping ...
SET CLASSPATH=%CLASSPATH%;target\classes
wsmapping.bat . . .
To create tables, run the wsmapping command from the ${profile_root}/bin directory. When completed, the database tables are created or updated. Messages and errors are logged to the administrative console as specified by log settings.
wsmapping.sh . . . On Windows :
To create the database tables needed for the Magazine.java file:
${profile_root}/bin/wsmapping.sh Magazine.java
${profile_root}/bin/wsmapping Magazine.java
${profile_root}\bin\wsmapping.sh Magazine.java
To drop the tables for Magazine.java:
C:\> %profile_root%/bin/wsmapping.sh -sa dropDB Magazine.java
C:\> %profile_root%/bin/wsmapping -sa dropDB Magazine.java
C:\> %profile_root%\bin\wsmapping.bat -sa dropDB Magazine.java
To validate the mappings for all classes on the class path:
C:\> %profile_root%/bin/wsmapping.sh -a validate
C:\> %profile_root%/bin/wsmapping -a validate
C:\> %profile_root%\bin\wsmapping.bat -a validate
See the mapping information in the Apache OpenJPA User Guide for more information and examples.