Java Reference
In-Depth Information
The JDO XML metadata specifies the persistence information and ORM meta-
data. The persistence information describes the persistent classes, each class's JDO
identity type, and which fields are persistent. The ORM metadata describes how
the domain model maps to the database schema. You can put the persistence
information and ORM metadata together in a .jdo file or you can put the mapping
in a separate .orm file. Most of the time you will want to put the metadata in a sin-
gle file, but separate files are useful if, for example, you want to map a domain
model to different database schemas.
The JDO XML metadata can be for either a single class or for one or more pack-
ages. If it is for a single class, the name of the name of the XML metadata file is <class-
Name>.jdo. If the metadata is for one or more packages, it is called package.jdo.
JDO defines a set of search rules for locating metadata files. You can, for example,
put a package.jdo file in a class path directory corresponding to the package name,
such as net/chrisrichardson/foodToGo/domain, or in a class path directory cor-
responding to a partial package name, such as net/chrisrichardson/foodToGo.
Listing 5.3 shows an excerpt of the JDO metadata for the PendingOrder class.
Listing 5.3
XML metadata for the PendingOrder class
<jdo>
<class name="PendingOrder"
table="PENDING_ORDER"
identity-type="application" >
B Configures
class mapping
<field name="id" primary-key="true"
value-strategy="native">
<column name="PENDING_ORDER_ID"/>
</field>
C Configures id as
primary key field
D Maps
deliveryTime
field
<field name="deliveryTime">
<column name="DELIVERY_TIME" jdbc-type="TIMESTAMP"/>
</field>
<field name="deliveryAddress"
default-fetch-group="true">
<embedded
null-indicator-column="DELIVERY_STREET1">
<field name="street1">
<column name="DELIVERY_STREET1"/>
</field>
<field name="street2">
<column name="DELIVERY_STREET2"/>
</field>
E Maps
deliveryAddress field
 
 
 
Search WWH ::




Custom Search