3.8.1.1. Using the Mapping Tool

The JPA specification defines a comprehensive set of defaults for missing mapping information. Thus, forward mapping in JPA is virtually automatic. After using the mapping annotations covered in Mapping Metadata of the JPA Overview to override any unsatisfactory defaults, run the mapping tool on your persistent classes. The default buildSchema mapping tool action manipulates the database schema to match your mappings. It fails if any of your mappings don’t match your object model.

Example 103. Creating the Relational Schema from Mappings
java org.apache.openjpa.jdbc.meta.MappingTool Magazine.java

To drop the schema for a persistent class, set the mapping tool’s schemaAction to drop.

Example 104. Refreshing entire schema and cleaning out tables

java org.apache.openjpa.jdbc.meta.MappingTool -schemaAction add,deleteTableContents
Example 105. Dropping Mappings and Association Schema
java org.apache.openjpa.jdbc.meta.MappingTool -schemaAction drop Magazine.java