WAS v8.5 > Reference > Command-line utilities

wsmapping command

The wsmapping tool is used to provide top-down mapping of the entity object model to the database relational model. We can use the wsmapping tool to create database tables.


Syntax

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:


Parameters

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

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

If we do not supply any arguments to the wsmapping tool, it runs on the classes in the persistent classes list.


Usage

Before running the wsmapping tool, 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 the 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 ...
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 dmgr console as specified by log settings.

wsmapping.sh . . . On Windows :

By specifying the buildSchema parameter to the openjpa.jdbc.SynchronizeMappings property, the mapping tool provides the default mapping that matches with the database schema automatically. You are not required to run this mapping tool if the default mapping satisfies the necessary database schema.


Examples

To create the database tables needed for the Magazine.java file:

To drop the tables for Magazine.java:

To validate the mappings for all classes on the class path:


Additional information

See the mapping information in the Apache OpenJPA User Guide for more information and examples.


Reference:

Develop JPA 2.x applications for a Java EE environment
Develop JPA 2.x applications for a Java SE environment

Apache OpenJPA User's Guide


+

Search Tips   |   Advanced Search