JPOX
JPOX
 JPOX Version 1.0
Configuration | Tutorials | Worked Examples | Developer
Obtaining JPOX
JPOX Preparation
JPOX Runtime
JDO Mode : New Schema

This is chosen when you have no legacy database, and so can allow the JDO implementation full control over the schema. JPOX can be used to generate the schema before you run your application for the first time using the SchemaTool utility, or you can set the property org.jpox.autoCreateSchema=true (see the Configuration Guide for details) so that the tables are created automatically when they are encountered. Alternatively you can create the schema yourself manually - though this could be error prone because you would, in effect, be second-guessing the types to be assigned by JPOX to columns.

datastore identity

This mode is chosen when you don't need/want to control the ids of your tables in your new schema. If you have a class as follows

public class Person
{
    protected String forename;
    protected String surname;
}
                

you would define the Meta-Data for this as follows

    <class name="Person" identity-type="datastore">
        <field name="forename">
            <extension vendor-name="jpox" key="length" value="max 80"/>
        </field>
        <field name="surname">
            <extension vendor-name="jpox" key="length" value="max 100"/>
        </field>
    </class>
                

That is, you specify the identity-type as datastore. This is, strictly speaking not necessary since this is the default identity-type.

application identity

This mode of operation is chosen when you want to control the ids of your tables (due to constraints on uniqueness etc on the columns) within your new schema. If you have a class as follows

public class Person
{
    protected int id;
    protected String forename;
    protected String surname;
}
public class PersonKey implements Serializable
{
    public int id;
    public PersonKey(String str) {...}
    public PersonKey() {...}
    public boolean equals(Object obj) {...}
    public int hashCode() {...}
    public String toString() {...};
}
                

you would define the Meta-Data for this as follows

    <class name="Person" identity-type="application" 
                    objectid-class="org.jpox.samples.PersonKey">
        <field name="id" primary-key="true"/>
        <field name="forename">
            <extension vendor-name="jpox" key="length" value="max 80"/>
        </field>
        <field name="surname">
            <extension vendor-name="jpox" key="length" value="max 100"/>
        </field>
    </class>
                

That is, you specify the identity-type as application and you specify your objectid-class (the Primary Key class).