Next, we need to define how the class should be persisted. We do this by defining an XML metadata file. This usually includes all fields that will be persisted and any special vendor extensions.
<?xml version="1.0"?> <!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="test"> <class name="Person"> <field name="firstName"> <extension vendor-name="triactive" key="length" value="max 32"/> </field> <field name="lastName"> <extension vendor-name="triactive" key="length" value="max 32"/> </field> <field name="age"/> </class> </package> </jdo>
Note that the firstName and lastName fields both use the "triactive" vendor extension "length". This is required for any persistent String field so an appropriate database column can be created (i.e. CHAR, VARCHAR, etc.). The possible TJDO vendor extensions are listed in the metadata DTD documentation.