class Address {
String description;
Coordinates location;
}
class Coordinates {
double latitude;
double longitude;
}
class Employee {
String name;
Address address;
}
TABLE EMPLOYEE (
NAME VARCHAR(255),
DESCRIPTION VARCHAR(255),
LATITUDE DOUBLE,
LONGITUDE DOUBLE)
<class name="Employee" table="EMPLOYEE">
<field name="name" column="NAME"/>
<field name="address">
<embedded>
<field name="description" column="DESCRIPTION"/>
<field name="location">
<embedded>
<field name="latitude" column="LATITUDE"/>
<field name="longitude" column="LONGITUDE"/>
</embedded>
</field>
</embedded>
</field>
</class>
I'd like to add an embedded element to @Field of type @Embedded[ ]
but annotations cannot contain cyclic references.
As an alternative, we can flatten the nested embedded fields like this:
class Employee {
@Column(name="NAME")
String name;
@Embedded(nullIndicatorColumn="DESCRIPTION",
fields={
@Field(name="address.description", [EMAIL PROTECTED]
(name="DESCRIPTION")),
@Field(name="address.location.latitude", [EMAIL PROTECTED]
(name="LATITUDE")),
@Field(name="address.location.longitude", [EMAIL PROTECTED]
(name="LONGITUDE"))})
Address address; }We still need a way to annotate a nested embedded null indicator column. In the above example, Address might have a description but null location. To do this, we can add a nullIndicatorColumn to the @Field annotation, e.g.
@Field(name="address.location", nullIndicatorColumn="LATITUDE")
Summary of proposed changes:
1. Add element name() to @Field to name the fields of the embedded
mapping.
2. Allow dotted notation for field names for nested embedded.3. Add element nullIndicatorColumn to @Field to identify nested embedded null indicator.
Craig Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:[EMAIL PROTECTED] P.S. A good JDO? O, Gasp!
smime.p7s
Description: S/MIME cryptographic signature
