Primitive fields of persistence capable classes are:
· Fields of primitive type
· Fields of wrapper types of primitives types
· Fields of type java.lang.String
· Fields of type java.util.Locale
· Fields of type java.math.BigDecimal and java.math.BigInteger
· Fields of type java.util.Date, java.sql.Date, java.sql.Time and java.sql.Timestamp
Primitive fields (except primitive fields of primitive type) are supported as second class objects.
For each persistent field of a persistent-capable class, you must define a mapping to exactly one column in a database table.
All persistent fields of a persistent-capable class are usually mapped to the columns of a single database table. Mapping fields to more then one database table is called multi-table mapping,and may be reasonable for mapping legacy relational models and for some specific object-relational mapping patterns concerning collections of primitive fields and inheritance. These tables must have the same primary key fields. Therefore, all the tables to which a persistence capable class is mapped can be treated logically as one table.
You must define a mapping to a primary key column (and vice versa) for all primary key fields.
The class example.jdo.Department has two persistent fields - depid and name, which are mapped to the columns DEPID and NAME of table TMP_DEPARTMENT.
The corresponding XML files contain the following metadata:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jdo SYSTEM "jdo.dtd">
<jdo>
<package name="example.jdo">
<class name="Department" identity-type="application" objectid-class="Department$Id">
<field name="depid" persistence-modifier="persistent" primary-key="true"/>
<field name="name" persistence-modifier="persistent"/>
</class>
</package>
</jdo>
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0">
<package name="example.jdo">
<class name="Department">
<field name="depid">
<column name="DEPID" table="TMP_DEPARTMENT"/>
</field>
<field name="name">
<column name="NAME" table="TMP_DEPARTMENT"/>
</field>
</class>
</package>
</map>
You can map sets and collections of primitive fields to a binary column with unlimited size (BLOB).
When allowing null values for database columns, you should consider the different semantics in Java and in SQL. In this case, Java semantics cannot be guaranteed in JDOQL expressions such as field == null where field has value null.