Show TOC Start of Content Area

Object documentation Mapping Primitive Fields  Locate the document in its SAP Library structure

Definition

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.

Use

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.

Example

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.

This graphic is explained in the accompanying text

 

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>

Sets and Collections of Primitive Fields

You can map sets and collections of primitive fields to a binary column with unlimited size (BLOB).

Null Values

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.

 

 

End of Content Area