JPOX
JPOX
 JPOX Version 1.0
Configuration | Tutorials | Worked Examples | Developer
Obtaining JPOX
JPOX Preparation
JPOX Runtime
Meta-Data

Java Persistent Objects JDO (JPOX) accepts standard JDO Meta-Data, and also a selection of vendor extensions. These are documented below, and are split into Class-level and Field-level. It should be noted that the JPOX vendor extensions are optional and you can operate JPOX with no extensions.

File Locations

JDO (1.0.1) expects the Meta-Data to be specified in a file or files in particular positions in the file system. For example, if you have a class com.mycompany.sample.myexample, JDO will look for any of the following files until it finds one (in the order stated) :-

META-INF/package.jdo
WEB-INF/package.jdo
package.jdo
com/package.jdo
com/mycompany/package.jdo
com/mycompany/sample/package.jdo
com/mycompany/sample/myexample.jdo
                

In addition, for this example, JPOX allows the previous JDO 1.0.0 alternatives of

com.jdo
com/mycompany.jdo
com/mycompany/sample.jdo
                
Mixing file locations

In addition to the above, you can split your MetaData definitions between JDO MetaData files. For example if you have the following classes

com/mycompany/A.java
com/mycompany/B.java
com/mycompany/C.java
com/mycompany/app1/D.java
com/mycompany/app1/E.java
                

You could define the MetaData for these 5 classes in many ways -- for example put all definitions in com/mycompany/package.jdo, or put the definitions for D and E in com/mycompany/app1/package.jdo and the definitions for A, B, C in com/mycompany/package.jdo, or have some in their class named MetaData files e.g com/mycompany/app1/A.jdo, or a mixture of the above. JPOX will always search for the MetaData file containing the class definition for the class that it requires.

Document Type Definitions and DOCTYPE Header Information

The contents in your XML files must conform to the Document Type Definition (DTD) for the jdo file you provide. It is mandatory to include the correct DOCTYPE header for each jdo file, and either SYSTEM or PUBLIC forms can be used. The DOCTYPE header information must include a valid URL syntax in order to avoid parser errors.

JDO versionFormElement String
1.0.1PUBLIC"-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 1.0//EN"

"http://java.sun.com/dtd/jdo_1_0.dtd"
1.0.1SYSTEM"file:/javax/jdo/jdo.dtd"

Metadata for package tag

These are attributes within the <package> tag (jdo/package).

AttributeDescriptionValues
Standard (JDO) Tags
nameName of the java package
Metadata for class tag

These are attributes within the <class> tag (jdo/package/class).

AttributeDescriptionValues
Standard (JDO) Tags
identity-typeThe identity type, specifying whether they are uniquely provided by the JDO implementation (datastore identity), accessible fields in the object (application identity), or not at all (nondurable identity). datastore, application, nondurable
objectid-classThe class name of the primary key (when using application identity)
requires-extentWhether the JDO implementation must provide an Extent for this class. true, false
persistence-capable-superclassClass name of superclass that is persistent capable
nameName of the class to persist

These are attributes within the <extension> tag (jdo/package/class/extension).

table-name
DescriptionTable name to use when persisting to the database (overriding the JPOX provided table name). See also the property name "org.jpox.store.Dictionary.CaseIdentifier" in the Configuration Guide.
Range of Values
Example
key-column-name
DescriptionColumn name to use when in "datastore identity" mode and adding an id column (by default the id column will be the 'table-name'_ID).
Range of Values
Example
key-auto-increment
DescriptionWhether to auto-increment the key column when in "datastore identity" mode.
Range of Valuestrue | false
Default Valuefalse
Example
use-poid-generator
DescriptionWhen in "application identity" mode, whether to use the POID generator to generate ids for this class's datastore representation.
Range of Valuestrue | false
Default Valuefalse
Example
poid-class-generator
DescriptionWhich form of generator to use for generating primary keys when in datastore identity mode.
Range of Valuesorg.jpox.poid.SequenceTablePoidGenerator |org.jpox.poid.MaxPoidGenerator | org.jpox.poid.OracleSequencePoidGenerator | org.jpox.poid.PostgresqlSequencePoidGenerator | Your custom generator class
Defaultorg.jpox.poid.SequenceTablePoidGenerator
Example
sequence-name
DescriptionThe sequence name for use by poid generators. These are the name for datastore sequences when using datastore identity mode. See Object Identity Generation.
Range of Values
RequirementsRequired when using an poid generator that requires this extension. See Object Identity Generation.
Example
sequence-table-name
DescriptionThe table name used to store sequences for use by poid generators. When using datastore identity mode. See Object Identity Generation.
Range of Values
RequirementsOptional. A default of "SEQUENCE_TABLE" will be used otherwise. See Object Identity Generation.
Example
sequence-name-column-name
DescriptionThe column name in the sequence-table used to store the name of the sequence for use by poid generators. When using datastore identity mode. See Object Identity Generation.
Range of Values
RequirementsOptional. A default of "SEQUENCE_NAME" will be used otherwise. See Object Identity Generation.
Example
sequence-nextval-column-name
DescriptionThe column name in the sequence-table used to store the next value in the sequence for use by poid generators. When using datastore identity mode. See Object Identity Generation.
Range of Values
RequirementsOptional. A default of "NEXT_VAL" will be used otherwise. See Object Identity Generation.
Example
key-min-value
DescriptionThe minimum key value for use by poid generators. Keys lower than this will not be generated. See Object Identity Generation.
Range of Values
RequirementsRequired when using an poid generator that requires this extension. See Object Identity Generation.
Example
key-max-value
DescriptionThe maximum key value for use by poid generators. Keys higher than this will not be generated. See Object Identity Generation.
Range of Values
RequirementsRequired when using an poid generator that requires this extension. See Object Identity Generation.
Example
key-start-with
DescriptionThe starting value for use by poid generators. Keys will start from this value when being generated. See Object Identity Generation.
Range of Values
RequirementsRequired when using an poid generator that requires this extension. See Object Identity Generation.
Example
key-increment-by
DescriptionThe increment value for use by poid generators. Keys will be incremented by this value when being generated. See Object Identity Generation.
Range of Values
RequirementsRequired when using an poid generator that requires this extension. See Object Identity Generation.
Example
key-database-cache-size
DescriptionThe database cache size for keys for use by poid generators. The cache of keys will be constrained by this value. See Object Identity Generation.
Range of Values
RequirementsRequired when using an poid generator that requires this extension. See Object Identity Generation.
Example
key-cache-size
DescriptionThe cache size for keys for use by poid generators. The cache of keys will be constrained by this value. See Object Identity Generation.
Range of Values
RequirementsRequired when using an poid generator that requires this extension. See Object Identity Generation.
Example
optimistic-mode
DescriptionThe mode to check for optimistic conflicts. The Version mode uses an incremental numbered value, and the Timestamp mode uses a java.sql.Timestamp value.
Range of ValuesVersion | Timestamp
Example
optimistic-column-name
DescriptionThe column name for the version or timestamp values.
Range of Values
Example
Metadata for field tag

These are attributes within the <field> tag (jdo/package/class/field).

AttributeDescriptionValues
Standard (JDO) Tags
nameName of the field.
persistence-modifierThe persistence-modifier specifies how JDO manage each field in your persistent class. There are three options: persistent, transactional and none.
  • A persistent value means that your field will managed by JDO and stored in the database on transaction commit.
  • A transactional value means that your field will managed by JDO but not stored in the database. Transactional fields values will be saved by JDO when you start your transaction and restored when you roll back your transaction.
  • A none value means that your field will not be managed by JDO.
persistent, transactional, none
primary-keyWhether the field is part of any primary key (if using application identity).true, false
null-valueHow to treat null values of persistent fields during storage. Valid options are "exception", "default", "none" (where "none" is the default).exception, default, none
embeddedWhether this field should be stored, if possible, as part of the object instead as its own object in the datastore. This defaults to true for primitive types, java.util.Date, java.lang.*, java.math.* etc. true, false
default-fetch-groupWhether this field is part of the default fetch group for the class. Defaults to true for non-key fields of primitive types, java.util.Date, java.lang.*, java.math.*, etc. true, false

These are attributes within the <extension> tag (jdo/package/class/field/extension).

length
DescriptionLength of this field in the database (for String field types).
Range of Values'positive integer' | unlimited | max 'positive integer'
Default Valuemax 127
Example For RDBMS VARCHAR types:

<!-- RDMBS database column type: VARCHAR 100 -->
<extension vendor-name="jpox" key="length" value="max 100" />
                            
For RDBMS CHAR types:

<!-- RDMBS database column type: CHAR 50 -->
<extension vendor-name="jpox" key="length" value="50" />
                            
For RDBMS BLOB, IMAGE, BYTE or LONGVARCHAR types:

<extension vendor-name="jpox" key="length" value="unlimited" />
                            
precision
DescriptionPrecision of this field in the database (for floating point field types)
Range of Values'integer', or 'min integer'
Example
<extension vendor-name="jpox" key="precision" value="1" />
                            
scale
DescriptionScale of this field in the database (for floating point field types)
Range of Values'integer'
Example
<extension vendor-name="jpox" key="scale" value="10" />
                            
key-length
DescriptionLength of this field in the database (for map key String field types)
Range of Values'positive integer' | unlimited | max 'positive integer'
Default Valuemax 127
Example For RDBMS VARCHAR types:

<!-- RDMBS database column type: VARCHAR 100 -->
<extension vendor-name="jpox" key="key-length" value="max 100" />
                            
For RDBMS CHAR types:

<!-- RDMBS database column type: CHAR 50 -->
<extension vendor-name="jpox" key="key-length" value="50" />
                            
For RDBMS BLOB, IMAGE, BYTE or LONGVARCHAR types:

<extension vendor-name="jpox" key="key-length" value="unlimited" />
                            
key-precision
DescriptionPrecision of this field in the database (for map key floating point field types)
Range of Values'integer', or 'min integer'
Example
<extension vendor-name="jpox" key="key-precision" value="1" />
                            
key-scale
DescriptionScale of this field in the database (for map key floating point field types)
Range of Values'integer'
Example
<extension vendor-name="jpox" key="key-scale" value="10" />
                            
value-length
DescriptionLength of this field in the database (for map value String field types)
Range of Values'positive integer' | unlimited | max 'positive integer'
Default Valuemax 127
Example For RDBMS VARCHAR types:

<!-- RDMBS database column type: VARCHAR 100 -->
<extension vendor-name="jpox" key="value-length" value="max 100" />
                            
For RDBMS CHAR types:

<!-- RDMBS database column type: CHAR 50 -->
<extension vendor-name="jpox" key="value-length" value="50" />
                            
For RDBMS BLOB, IMAGE, BYTE or LONGVARCHAR types:

<extension vendor-name="jpox" key="value-length" value="unlimited" />
                            
value-precision
DescriptionPrecision of this field in the database (for map value floating point field types)
Range of Values'integer', or 'min integer'
Example
<extension vendor-name="jpox" key="value-precision" value="1" />
                            
value-scale
DescriptionScale of this field in the database (for map value floating point field types)
Range of Values'integer'
Example
<extension vendor-name="jpox" key="value-scale" value="10" />
                            
collection-field
DescriptionWhether this field is the "many" end of a "1-to-N" relationship
Range of Values
RequirementsRequired when using double-ended relationships with Collection type fields, also know as inverse relationships.
Example
list-field
DescriptionName of the List field in the owner class.
Range of Values
RequirementsRequired when using double-ended relationships with List type fields, also know as inverse relationships.
Example
map-field
DescriptionName of the Map field in the owner class.
Range of Values
RequirementsRequired when using double-ended relationships with Map type fields, also know as inverse relationships.
Example
column-name
DescriptionColumn name to use when persisting to the database (overriding the JPOX provided column name). See also the property name "org.jpox.store.Dictionary.CaseIdentifier" in the Configuration Guide.
Range of Values
Example
key-auto-increment
DescriptionWhether to auto-increment this column when in "application identity" mode.
Range of Valuestrue | false
Default Valuefalse
Example
poid-class-generator
DescriptionWhich form of generator to use for generating primary keys.
Range of Valuesorg.jpox.poid.SequenceTablePoidGenerator | org.jpox.poid.MaxPoidGenerator | org.jpox.poid.OracleSequencePoidGenerator | org.jpox.poid.PostgresqlSequencePoidGenerator | Your custom generator class
Defaultorg.jpox.poid.SequenceTablePoidGenerator
Example
sequence-name
DescriptionThe sequence name for use by poid generators. These are the name for datastore sequences. See Object Identity Generation.
Range of Values
RequirementsRequired when using an poid generator that requires this extension. See Object Identity Generation.
Example
sequence-table-name
DescriptionThe table name used to store sequences for use by poid generators. When using application identity mode. See Object Identity Generation.
Range of Values
RequirementsOptional. A default of "SEQUENCE_TABLE" will be used otherwise. See Object Identity Generation.
Example
sequence-name-column-name
DescriptionThe column name in the sequence-table used to store the name of the sequence for use by poid generators. When using application identity mode. See Object Identity Generation.
Range of Values
RequirementsOptional. A default of "SEQUENCE_NAME" will be used otherwise. See Object Identity Generation.
Example
sequence-nextval-column-name
DescriptionThe column name in the sequence-table used to store the next value in the sequence for use by poid generators. When using application identity mode. See Object Identity Generation.
Range of Values
RequirementsOptional. A default of "NEXT_VAL" will be used otherwise. See Object Identity Generation.
Example
key-min-value
DescriptionThe minimum key value for use by poid generators. Keys lower than this will not be generated. See Object Identity Generation.
Range of Values
RequirementsRequired when using an poid generator that requires this extension. See Object Identity Generation.
Example
key-max-value
DescriptionThe maximum key value for use by poid generators. Keys higher than this will not be generated. See Object Identity Generation.
Range of Values
RequirementsRequired when using an poid generator that requires this extension. See Object Identity Generation.
Example
key-start-with
DescriptionThe starting value for use by poid generators. Keys will start from this value when being generated. See Object Identity Generation.
Range of Values
RequirementsRequired when using an poid generator that requires this extension. See Object Identity Generation.
Example
key-increment-by
DescriptionThe increment value for use by poid generators. Keys will be incremented by this value when being generated. See Object Identity Generation.
Range of Values
RequirementsRequired when using an poid generator that requires this extension. See Object Identity Generation.
Example
key-database-cache-size
DescriptionThe database cache size for keys for use by poid generators. The cache of keys will be constrained by this value. See Object Identity Generation.
Range of Values
RequirementsRequired when using an poid generator that requires this extension. See Object Identity Generation.
Example
key-cache-size
DescriptionThe cache size for keys for use by poid generators. The cache of keys will be constrained by this value. See Object Identity Generation.
Range of Values
RequirementsRequired when using an poid generator that requires this extension. See Object Identity Generation.
Example
index-column-name
DescriptionName of the column that is used for indexing a list when an Inverse List is used. If you have a Normal List, please look at the tags under "collection".
Range of Values
Example
implementation-classes
DescriptionUsed to define the possible classes implementing this interface field. This is used to limit the possible tables that this is a foreign key to (when this field is specified as an interface in the class).
Range of Values Fully qualified class name[,Fully qualified class name]
RequirementsRequired when persistent fields are declared with Interface types
Example
key-implementation-classes
DescriptionUsed to define the possible classes implementing this interface key. This is used to limit the possible tables that this is a foreign key to (when this key is specified as an interface).
Range of Values Fully qualified class name[,Fully qualified class name]
RequirementsRequired when persistent keys are declared with Interface types
Example
value-implementation-classes
DescriptionUsed to define the possible classes implementing this interface value. This is used to limit the possible tables that this is a foreign key to (when this value is specified as an interface).
Range of Values Fully qualified class name[,Fully qualified class name]
RequirementsRequired when persistent values are declared with Interface types
Example
view-imports
DescriptionClasses imported to the JPOXQL. See Query
Range of Values
Example
view-definition
DescriptionDefinition of the VIEW to be used by the class.
Range of Values
Example
Metadata for collection tag

These are attributes within the <collection> tag (jdo/package/class/field/collection).

AttributeDescriptionValues
Standard (JDO) Tags
element-typeThe type of element stored in this Collection (fully qualified class).
embedded-elementWhether the elements of a collection or array-valued persistent field should be stored embedded or as first-class objects. It's a hint for the JDO implementation to store, if possible, the elements of the collection as part of the it instead of as their own instances in the datastore. For RDBMS databases it means that the element might be stored in a BLOB column. true, false

These are attributes within the <extension> tag (jdo/package/class/field/collection/extension).

owner-field
DescriptionWhether this field is the "one" side of a 1-to-N relationship.
Range of Values
RequirementsRequired when using double-ended relationships, also know as inverse relationships.
Example
clear-on-delete
DescriptionWhether to clear any index to the owner on deletion of the owner object.
Range of Valuestrue | false
Default Valuetrue
Example
table-name
DescriptionTable name to use for any join table overriding the default name provided by JPOX. See also the property name "org.jpox.store.Dictionary.CaseIdentifier" in the Configuration Guide.
Range of Values
Example
owner-column-name
DescriptionName of the owner column(s) on any join table when this class is the owner table for a relationship. If the owner table has a composite primary key you should specify a comma-separated list of column names here.
Range of Values
Example
element-column-name
DescriptionName of the element column(s) on any join table when this class is the owner table for a relationship. If the element table has a composite primary key you should specify a comma-separated list of column names here.
Range of Values
Example
index-column-name
DescriptionName of the index column on any join table when this class is the owner table for a Normal List
Range of Values
Example
Metadata for map tag

These are attributes within the <map> tag (jdo/package/class/field/map).

AttributeDescriptionValues
Standard (JDO) Tags
key-typeThe type of key stored in this Map (fully qualified class).
embedded-keyWhether the elements of a Map key field should be stored embedded or as first-class objects.true, false
value-typeThe type of value stored in this Map (fully qualified class).
embedded-valueWhether the elements of a Map value field should be stored embedded or as first-class objects.true, false

These are attributes within the <extension> tag (jdo/package/class/field/map/extension).

owner-field
DescriptionWhether this field is the "one" side of a 1-to-N relationship.
Range of Values
RequirementsRequired when using double-ended relationships, also know as inverse relationships.
Example
key-field
DescriptionName of the key field in the value class.
Range of Values
RequirementsRequired when using double-ended relationships, also know as inverse relationships.
Example
clear-on-delete
DescriptionWhether to clear any index to the owner on deletion of the owner object.
Range of Valuestrue | false
Default Valuefalse
Example
table-name
DescriptionTable name to use for any join table overriding the default name provided by JPOX. See also the property name "org.jpox.store.Dictionary.CaseIdentifier" in the Configuration Guide.
Range of Values
Example
owner-column-name
DescriptionName of the owner column(s) on any join table when this class is the owner table for a relationship. If the owner table has a composite primary key you should specify a comma-separated list of column names here.
Range of Values
Example
key-column-name
DescriptionName of the key column(s) on any join table when this class is the owner table for a relationship. If the key table has a composite primary key you should specify a comma-separated list of column names here.
Range of Values
Example
value-column-name
DescriptionName of the value column(s) on any join table when this class is the owner table for a relationship. If the value table has a composite primary key you should specify a comma-separated list of column names here.
Range of Values
Example
Metadata for array tag

The only arrays currently supported by JPOX are byte arrays, and these are always stored as embedded.

AttributeDescriptionValues
Standard (JDO) Tags
embedded-elementWhether the array elements should be stored embedded or as first-class objects.true, false
Sample MetaData

Let us take a sample class and generate MetaData for it. Suppose I have a class as follows

package org.jpox.mysample;

public class Person
{
    /** Title of the Person. */
    String title=null;

    /** Forename of the Person. */
    String forename=null;

    /** Surname of the Person. */
    String surname=null;

    ...
}
                

and I want to use an existing schema. With this case I need to define the table and column names that it maps to. To do this I need to use JPOX extension tags. So I come up with MetaData as follows

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jdo PUBLIC
    "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 1.0//EN"
    "http://java.sun.com/dtd/jdo_1_0.dtd">
<jdo>
<package name="org.jpox.mysample">
    <class name="Person"
        identity-type="datastore">
        <extension vendor-name="jpox" key="table-name" value="PERSON"/>
        <field name="title">
            <extension vendor-name="jpox" key="column-name" value="TITLE"/>
        </field>
        <field name="forename">
            <extension vendor-name="jpox" key="column-name" value="FORENAME"/>
            <extension vendor-name="jpox" key="length" value="max 100"/>
        </field>
        <field name="surname">
            <extension vendor-name="jpox" key="column-name" value="SURNAME"/>
            <extension vendor-name="jpox" key="length" value="max 100"/>
        </field>
    </class>
</package>
</jdo>
                

So you see that our class is being mapped across to a table "PERSON" in the datastore, with columns "TITLE", "FORENAME", "SURNAME". We have also specified that the upper size limit on the forename and surname fields is 100.