+

Search Tips   |   Advanced Search

wsmapping command


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

Use the wsmapping tool to create database tables.

 

Syntax

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

The command syntax is as follows: [AIX] [HP-UX] [Linux] [Solaris]

wsmapping.sh [options][arguments]

(Windows)

wsmapping.bat [options][arguments]

 

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, we need to configure the datasource 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 classpath (assume entity class files can be found in target/classes) ...
[AIX] [HP-UX] [Linux]

(UNIX) [Solaris]

export CLASSPATH=${CLASSPATH}:target/classes 
 wsmapping.sh ...

(Windows)

SET CLASSPATH=%CLASSPATH%;target\classes  
 wsmapping.bat . . .

To create tables, run the wsmapping command from the ${WAS_HOME}/bin directory. When completed, the database tables are created or updated. Messages and errors are logged to the console as specified by log settings.

wsmapping.sh . . . On Windows :

Tip: 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. we 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: [AIX] [HP-UX] [Linux] [Solaris]

${WAS_HOME}/bin/wsmapping.sh Magazine.java

(Windows)

${WAS_HOME}\bin\wsmapping.sh Magazine.java
To drop the tables for Magazine.java: [AIX] [HP-UX] [Linux] [Solaris]

C:\> %WAS_HOME%/bin/wsmapping.sh -sa dropDB Magazine.java

(Windows)

C:\> %WAS_HOME%\bin\wsmapping.bat -sa dropDB Magazine.java

To validate the mappings for all classes on the classpath: [AIX] [HP-UX] [Linux] [Solaris]

C:\> %WAS_HOME%/bin/wsmapping.sh -a validate

(Windows)

C:\> %WAS_HOME%\bin\wsmapping.bat -a validate

 

Additional information

Consult chapter 7, Mapping in the OpenJPA reference documentation for more information and examples.



 

Related


Develop and packaging JPA applications for a Java EE environment
Develop and packaging JPA applications for a Java SE environment

 

Related information


http://openjpa.apache.org/docs/latest/manual/manual.html#ref_guide_mapping_mappingtool