Skip Headers

# Using Java

Previous

Next

Example: Creating a Relational Descriptor in Java shows how to create a relational descriptor using Java code.

Creating a Relational Descriptor in Java

    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(YourClass.class);

To designate a relational descriptor as an aggregate, use `ClassDescriptor` method `descriptorIsAggregate`. For a `RelationalDescriptor` configured as an aggregate, you do not define a primary key, but when using Java, you must configure the associated table (see "Configuring Associated Tables") and field mappings (see "Understanding Mappings").

To allow a relational descriptor to participate in an aggregate collection mapping (see "Aggregate Collection Mapping"), use `ClassDescriptor` method `descriptorIsAggregateCollection`. For a `RelationalDescriptor` configured for use with an aggregate collection mapping, you do define primary keys (see "Configuring Primary Keys") and an associated table (see "Configuring Associated Tables"), but you do not have to map the primary keys if they are shared from their parent.

To configure a relational descriptor for an interface, use `ClassDescriptor` method `setJavaInterface`, passing in the `java.lang.Class` of the interface. You should only use an interface descriptor for an interface that has multiple implementors. If an interface has only a single implementor, then rather than creating an interface descriptor, just set the implementor descriptor's interface alias (see "Configuring Interface Alias").