|
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.
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
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.
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 version | Form | Element String |
|---|
| 1.0.1 | PUBLIC | "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 1.0//EN" "http://java.sun.com/dtd/jdo_1_0.dtd" | | 1.0.1 | SYSTEM | "file:/javax/jdo/jdo.dtd" |
These are attributes within the <package> tag (jdo/package).
| Attribute | Description | Values |
|---|
|
Standard (JDO) Tags
| | name | Name of the java package | |
These are attributes within the <class> tag (jdo/package/class).
| Attribute | Description | Values |
|---|
|
Standard (JDO) Tags
| | identity-type | The 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-class | The class name of the primary key (when using application identity) | | | requires-extent | Whether the JDO implementation must provide an Extent for this class. |
true, false | | persistence-capable-superclass | Class name of superclass that is persistent capable | | | name | Name of the class to persist | |
These are attributes within the <extension> tag (jdo/package/class/extension).
|
table-name
|
|---|
| Description | Table 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
|
|---|
| Description | Column 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
|
|---|
| Description | Whether to auto-increment the key column when in "datastore identity" mode. | | Range of Values | true | false | | Default Value | false | | Example |
|
|
use-poid-generator
|
|---|
| Description | When in "application identity" mode, whether to use the POID generator to generate ids for this class's datastore representation. | | Range of Values | true | false | | Default Value | false | | Example |
|
|
poid-class-generator
|
|---|
| Description | Which form of generator to use for generating primary keys when in datastore identity mode. | | Range of Values | org.jpox.poid.SequenceTablePoidGenerator |org.jpox.poid.MaxPoidGenerator | org.jpox.poid.OracleSequencePoidGenerator | org.jpox.poid.PostgresqlSequencePoidGenerator | Your custom generator class
| | Default | org.jpox.poid.SequenceTablePoidGenerator | | Example |
|
|
sequence-name
|
|---|
| Description | The 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 | | | Requirements | Required when using an poid generator that requires this extension. See Object Identity Generation. | | Example |
|
|
sequence-table-name
|
|---|
| Description | The table name used to store sequences for use by poid generators. When using datastore identity mode. See Object Identity Generation. | | Range of Values | | | Requirements | Optional. A default of "SEQUENCE_TABLE" will be used otherwise. See Object Identity Generation. | | Example |
|
|
sequence-name-column-name
|
|---|
| Description | The 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 | | | Requirements | Optional. A default of "SEQUENCE_NAME" will be used otherwise. See Object Identity Generation. | | Example |
|
|
sequence-nextval-column-name
|
|---|
| Description | The 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 | | | Requirements | Optional. A default of "NEXT_VAL" will be used otherwise. See Object Identity Generation. | | Example |
|
|
key-min-value
|
|---|
| Description | The minimum key value for use by poid generators. Keys lower than this will not be generated. See Object Identity Generation. | | Range of Values | | | Requirements | Required when using an poid generator that requires this extension. See Object Identity Generation. | | Example |
|
|
key-max-value
|
|---|
| Description | The maximum key value for use by poid generators. Keys higher than this will not be generated. See Object Identity Generation. | | Range of Values | | | Requirements | Required when using an poid generator that requires this extension. See Object Identity Generation. | | Example |
|
|
key-start-with
|
|---|
| Description | The starting value for use by poid generators. Keys will start from this value when being generated. See Object Identity Generation. | | Range of Values | | | Requirements | Required when using an poid generator that requires this extension. See Object Identity Generation. | | Example |
|
|
key-increment-by
|
|---|
| Description | The increment value for use by poid generators. Keys will be incremented by this value when being generated. See Object Identity Generation. | | Range of Values | | | Requirements | Required when using an poid generator that requires this extension. See Object Identity Generation. | | Example |
|
|
key-database-cache-size
|
|---|
| Description | The 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 | | | Requirements | Required when using an poid generator that requires this extension. See Object Identity Generation. | | Example |
|
|
key-cache-size
|
|---|
| Description | The 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 | | | Requirements | Required when using an poid generator that requires this extension. See Object Identity Generation. | | Example |
|
|
optimistic-mode
|
|---|
| Description | The 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 Values | Version | Timestamp | | Example |
|
|
optimistic-column-name
|
|---|
| Description | The column name for the version or timestamp values. | | Range of Values | | | Example |
|
These are attributes within the <field> tag (jdo/package/class/field).
| Attribute | Description | Values |
|---|
|
Standard (JDO) Tags
| | name | Name of the field. | | | persistence-modifier | The 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-key | Whether the field is part of any primary key (if using application identity). | true, false
| | null-value | How to treat null values of persistent fields during storage. Valid options are "exception", "default", "none" (where "none" is the default). | exception, default, none
| | embedded | Whether 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-group | Whether 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
|
|---|
| Description | Length of this field in the database (for String field types). | | Range of Values | 'positive integer' | unlimited | max 'positive integer' | | Default Value | max 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
|
|---|
| Description | Precision 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
|
|---|
| Description | Scale 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
|
|---|
| Description | Length of this field in the database (for map key String field types) | | Range of Values | 'positive integer' | unlimited | max 'positive integer' | | Default Value | max 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
|
|---|
| Description | Precision 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
|
|---|
| Description | Scale 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
|
|---|
| Description | Length of this field in the database (for map value String field types) | | Range of Values | 'positive integer' | unlimited | max 'positive integer' | | Default Value | max 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
|
|---|
| Description | Precision 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
|
|---|
| Description | Scale 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
|
|---|
| Description | Whether this field is the "many" end of a "1-to-N" relationship | | Range of Values | | | Requirements | Required when using double-ended relationships with Collection type fields, also know as inverse relationships. | | Example |
|
|
list-field
|
|---|
| Description | Name of the List field in the owner class. | | Range of Values | | | Requirements | Required when using double-ended relationships with List type fields, also know as inverse relationships. | | Example |
|
|
map-field
|
|---|
| Description | Name of the Map field in the owner class. | | Range of Values | | | Requirements | Required when using double-ended relationships with Map type fields, also know as inverse relationships. | | Example |
|
|
column-name
|
|---|
| Description | Column 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
|
|---|
| Description | Whether to auto-increment this column when in "application identity" mode. | | Range of Values | true | false | | Default Value | false | | Example |
|
|
poid-class-generator
|
|---|
| Description | Which form of generator to use for generating primary keys. | | Range of Values | org.jpox.poid.SequenceTablePoidGenerator | org.jpox.poid.MaxPoidGenerator | org.jpox.poid.OracleSequencePoidGenerator | org.jpox.poid.PostgresqlSequencePoidGenerator | Your custom generator class
| | Default | org.jpox.poid.SequenceTablePoidGenerator | | Example |
|
|
sequence-name
|
|---|
| Description | The sequence name for use by poid generators. These are the name for datastore sequences. See Object Identity Generation. | | Range of Values | | | Requirements | Required when using an poid generator that requires this extension. See Object Identity Generation. | | Example |
|
|
sequence-table-name
|
|---|
| Description | The table name used to store sequences for use by poid generators. When using application identity mode. See Object Identity Generation. | | Range of Values | | | Requirements | Optional. A default of "SEQUENCE_TABLE" will be used otherwise. See Object Identity Generation. | | Example |
|
|
sequence-name-column-name
|
|---|
| Description | The 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 | | | Requirements | Optional. A default of "SEQUENCE_NAME" will be used otherwise. See Object Identity Generation. | | Example |
|
|
sequence-nextval-column-name
|
|---|
| Description | The 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 | | | Requirements | Optional. A default of "NEXT_VAL" will be used otherwise. See Object Identity Generation. | | Example |
|
|
key-min-value
|
|---|
| Description | The minimum key value for use by poid generators. Keys lower than this will not be generated. See Object Identity Generation. | | Range of Values | | | Requirements | Required when using an poid generator that requires this extension. See Object Identity Generation. | | Example |
|
|
key-max-value
|
|---|
| Description | The maximum key value for use by poid generators. Keys higher than this will not be generated. See Object Identity Generation. | | Range of Values | | | Requirements | Required when using an poid generator that requires this extension. See Object Identity Generation. | | Example |
|
|
key-start-with
|
|---|
| Description | The starting value for use by poid generators. Keys will start from this value when being generated. See Object Identity Generation. | | Range of Values | | | Requirements | Required when using an poid generator that requires this extension. See Object Identity Generation. | | Example |
|
|
key-increment-by
|
|---|
| Description | The increment value for use by poid generators. Keys will be incremented by this value when being generated. See Object Identity Generation. | | Range of Values | | | Requirements | Required when using an poid generator that requires this extension. See Object Identity Generation. | | Example |
|
|
key-database-cache-size
|
|---|
| Description | The 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 | | | Requirements | Required when using an poid generator that requires this extension. See Object Identity Generation. | | Example |
|
|
key-cache-size
|
|---|
| Description | The 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 | | | Requirements | Required when using an poid generator that requires this extension. See Object Identity Generation. | | Example |
|
|
index-column-name
|
|---|
| Description | Name 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
|
|---|
| Description | Used 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] | | Requirements | Required when persistent fields are declared with Interface types | | Example |
|
|
key-implementation-classes
|
|---|
| Description | Used 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] | | Requirements | Required when persistent keys are declared with Interface types | | Example |
|
|
value-implementation-classes
|
|---|
| Description | Used 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] | | Requirements | Required when persistent values are declared with Interface types | | Example |
|
|
view-imports
|
|---|
| Description | Classes imported to the JPOXQL. See Query
| | Range of Values | | | Example |
|
|
view-definition
|
|---|
| Description | Definition of the VIEW to be used by the class. | | Range of Values | | | Example |
|
These are attributes within the <collection> tag (jdo/package/class/field/collection).
| Attribute | Description | Values |
|---|
|
Standard (JDO) Tags
| | element-type | The type of element stored in this Collection (fully qualified class). | | | embedded-element | Whether 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
|
|---|
| Description | Whether this field is the "one" side of a 1-to-N relationship. | | Range of Values | | | Requirements | Required when using double-ended relationships, also know as inverse relationships. | | Example |
|
|
clear-on-delete
|
|---|
| Description | Whether to clear any index to the owner on deletion of the owner object. | | Range of Values | true | false | | Default Value | true | | Example |
|
|
table-name
|
|---|
| Description | Table 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
|
|---|
| Description | Name 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
|
|---|
| Description | Name 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
|
|---|
| Description | Name of the index column on any join table when this class is the owner table for a Normal List | | Range of Values | | | Example |
|
These are attributes within the <map> tag (jdo/package/class/field/map).
| Attribute | Description | Values |
|---|
|
Standard (JDO) Tags
| | key-type | The type of key stored in this Map (fully qualified class). | | | embedded-key | Whether the elements of a Map key field should be stored embedded or as first-class objects. | true, false | | value-type | The type of value stored in this Map (fully qualified class). | | | embedded-value | Whether 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
|
|---|
| Description | Whether this field is the "one" side of a 1-to-N relationship. | | Range of Values | | | Requirements | Required when using double-ended relationships, also know as inverse relationships. | | Example |
|
|
key-field
|
|---|
| Description | Name of the key field in the value class. | | Range of Values | | | Requirements | Required when using double-ended relationships, also know as inverse relationships. | | Example |
|
|
clear-on-delete
|
|---|
| Description | Whether to clear any index to the owner on deletion of the owner object. | | Range of Values | true | false | | Default Value | false | | Example |
|
|
table-name
|
|---|
| Description | Table 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
|
|---|
| Description | Name 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
|
|---|
| Description | Name 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
|
|---|
| Description | Name 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 |
|
The only arrays currently supported by JPOX are byte arrays, and these are always stored as embedded.
| Attribute | Description | Values |
|---|
|
Standard (JDO) Tags
| | embedded-element | Whether the array elements should be stored embedded or as first-class objects. | true, false |
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.
|