OpenJPA development tools share the same set of configuration defaults and overrides as the runtime system. They also allow you to specify property values on the command line:
-properties/-p <configuration file or resource>
: Use
the -properties
flag, or its shorter -p
form, to specify a configuration file to use. Note that OpenJPA always searches
the default file locations described above, so this flag is only needed when you
do not have a default resource in place, or when you wish to override the
defaults. The given value can be the path to a file, or the resource name of a
file somewhere in the CLASSPATH
. OpenJPA will search the
given location as well as the location prefixed by META-INF/
. Thus, to point an OpenJPA tool at
META-INF/my-persistence.xml
, you can use:
<tool> -p my-persistence.xml
If you want to run a tool against just one particular persistence unit in a configuration file, you can do so by specifying an anchor along with the resource. If you do not specify an anchor, the tools will run against all the persistence units defined within the specified resource, or the default resource if none is specified. If the persistence unit is defined within the default resource location, then you can just specify the raw anchor itself:
<tool> -p my-persistence.xml#sales-persistence-unit <tool> -p #invoice-persistence-unit
-<property name> <property value>
: Any
configuration property that you can specify in a configuration file can be
overridden with a command line flag. The flag name is always the last token of
the corresponding property name, with the first letter in either upper or lower
case. For example, to override the openjpa.ConnectionUserName
property, you could pass the -connectionUserName <value>
flag to any tool. Values set this way override both the values in the
configuration file and values set via System properties.
Some OpenJPA development tools generate Java code. These tools share a common
set of command-line flags for formatting their output to match your coding
style. All code formatting flags can begin with either the codeFormat
or cf
prefix.
-codeFormat./-cf.tabSpaces <spaces>
: The number of
spaces that make up a tab, or 0 to use tab characters. Defaults to using tab
characters.
-codeFormat./-cf.spaceBeforeParen <true/t | false/f>
:
Whether or not to place a space before opening parentheses on method calls, if
statements, loops, etc. Defaults to false
.
-codeFormat./-cf.spaceInParen <true/t | false/f>
:
Whether or not to place a space within parentheses; i.e. method( arg)
. Defaults to false
.
-codeFormat./-cf.braceOnSameLine <true/t | false/f>
:
Whether or not to place opening braces on the same line as the declaration that
begins the code block, or on the next line. Defaults to true
.
-codeFormat./-cf.braceAtSameTabLevel <true/t | false/f>
: When the braceOnSameLine
option is disabled, you can choose
whether to place the brace at the same tab level of the contained code. Defaults
to false
.
-codeFormat./-cf.scoreBeforeFieldName <true/t | false/f>
: Whether to prefix an underscore to names of private member
variables. Defaults to false
.
-codeFormat./-cf.linesBetweenSections <lines>
: The
number of lines to skip between sections of code. Defaults to 1.
Example 2.1. Code Formatting with the Application Id Tool
java org.apache.openjpa.enhance.ApplicationIdTool -cf.spaceBeforeParen true -cf.tabSpaces 4