The XDoclet module does not yet support nested objects, but it will in the
next release (end of january), perhaps even in the OJB 1.0 final. The
syntax will look like this (minor changes are possible):
/**
* @ojb.class table="CONTACT_PERSON"
*/
public class ContactPerson implements java.io.Serializable
{
/** @ojb.nested */
protected Address address;
/** @ojb.field column="NAME" */
protected String name;
...
}
/**
* Note that ojb.class is not necessary here for the nesting
* though the individual ojb.field tags are.
*/
public class Address implements java.io.Serializable {
/** @ojb.field column="STREET_NAME" */
protected String streetName
/** @ojb.field column="STREET_NUMBER" */
protected String streetNumber
/** @ojb.field column="ZIP_CODE" */
protected String zip;
...
}
This will result in something like (note the ordering):
<class-descriptor
class="be.gfdi.business.base.ContactPerson"
table="CONTACT_PERSON"
>
<field-descriptor
name="address::streetName"
column="STREET_NAME"
jdbc-type="VARCHAR"
/>
<field-descriptor
name="address::streetNumber"
column="STREET_NUMBER"
jdbc-type="VARCHAR"
/>
<field-descriptor
name="address::zip"
column="ZIP_CODE"
jdbc-type="VARCHAR"
/>
<field-descriptor
name="name"
column="NAME"
jdbc-type="VARCHAR"
/>
...
</class-descriptor>
To change the ordering or ignore fields you could modify the nested fields
like this:
/**
* @ojb.class table="CONTACT_PERSON"
*/
public class ContactPerson implements java.io.Serializable
{
/**
* @ojb.nested
* @ojb.modify-nested name="streetName"
* id="2"
* @ojb.modify-nested name="streetNumber"
* id="3"
* @ojb.modify-nested name="zip"
* ignore="true"
*/
protected Address address;
/**
* @ojb.field column="NAME"
* id="1"
*/
protected String name;
...
}
which results in
<class-descriptor
class="be.gfdi.business.base.ContactPerson"
table="CONTACT_PERSON"
>
<field-descriptor
name="name"
column="NAME"
jdbc-type="VARCHAR"
/>
<field-descriptor
name="address::streetName"
column="STREET_NAME"
jdbc-type="VARCHAR"
/>
<field-descriptor
name="address::streetNumber"
column="STREET_NUMBER"
jdbc-type="VARCHAR"
/>
...
</class-descriptor>
(This is a slightly contrieved example of the modify-nested tag as it
would suffice to use id for the "name" field).
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]