Skip Headers

# Using Java

Previous

Next

Example: Defining Interface Query Keys shows how to define the `Contact` interface and `Email` and `Phone` implementors in Java.

Defining Interface Query Keys

    Descriptor contactInterfaceDescriptor = new Descriptor();
        contactInterfaceDescriptor.setJavaInterface(Contact.class);
        contactInterfaceDescriptor.addAbstractQueryKey("id");
    Descriptor emailClassDescriptor = new Descriptor();
        emailClassDescriptor.setJavaClass(Email.class);
        emailClassDescriptor.addDirectQueryKey("id", "E_ID");
        emailClassDescriptor.getInterfacePolicy().addParentInterface(Contact.class);
        emailClassDescriptor.setTableName("INT_EML");
        emailClassDescriptor.setPrimaryKeyFieldName("E_ID");
        emailClassDescriptor.setSequenceNumberName("SEQ");
        emailClassDescriptor.setSequenceNumberFieldName("E_ID");
        emailClassDescriptor.addDirectMapping("emailID", "E_ID");
        emailClassDescriptor.addDirectMapping("address", "ADDR");
    Descriptor phoneClassDescriptor = new Descriptor();
        phoneClassDescriptor.setJavaClass(Phone.class);
        phoneClassDescriptor.getInterfacePolicy().addParentInterface(Contact.class);
        phoneClassDescriptor.addDirectQueryKey("id", "P_ID");
        phoneClassDescriptor.setTableName("INT_PHN");
        phoneClassDescriptor.setPrimaryKeyFieldName("P_ID");
        phoneClassDescriptor.setSequenceNumberName("SEQ");
        phoneClassDescriptor.setSequenceNumberFieldName("P_ID");
        phoneClassDescriptor.addDirectMapping("phoneID", "P_ID");
        phoneClassDescriptor.addDirectMapping("number", "P_NUM");