public static RelationalDescriptor descriptor() { RelationalDescriptor descriptor = new RelationalDescriptor(); /* First define the class, table and descriptor properties. */ descriptor.setJavaClass(Customer.class); descriptor.setTableName("EVENTCUSTOMER"); descriptor.setPrimaryKeyFieldName("ID"); descriptor.setSequenceNumberName("SEQ"); descriptor.setSequenceNumberFieldName("ID"); /* Next define the attribute mappings. */ OneToOneMapping addressMapping = new OneToOneMapping(); addressMapping.setAttributeName("address"); addressMapping.setReferenceClass(Address.class); addressMapping.dontUseIndirection(); addressMapping.privateOwnedRelationship(); addressMapping.addForeignKeyFieldName("EVENTCUSTOMER.ADDRESS_ID", "EADDRESS.ID"); descriptor.addMapping(addressMapping); OneToOneMapping phoneMapping = new OneToOneMapping(); phoneMapping.setAttributeName("phoneNumber"); phoneMapping.setReferenceClass(Phone.class); phoneMapping.dontUseIndirection(); phoneMapping.privateOwnedRelationship(); phoneMapping.addForeignKeyFieldName("EVENTCUSTOMER.PHONE_ID", "EPHONE.ID"); descriptor.addMapping(phoneMapping); OneToOneMapping emailMapping = new OneToOneMapping(); emailMapping.setAttributeName("email"); emailMapping.setReferenceClass(EmailAccount.class); emailMapping.dontUseIndirection(); emailMapping.privateOwnedRelationship(); emailMapping.addForeignKeyFieldName("EVENTCUSTOMER.EMAIL_ID", "EMAILACC.ID"); descriptor.addMapping(emailMapping); DirectCollectionMapping associationsMapping = new DirectCollectionMapping(); associationsMapping.setAttributeName("associations"); associationsMapping.dontUseIndirection(); associationsMapping.setReferenceTableName("EASSOCIATIONS"); associationsMapping.setDirectFieldName("EASSOCIATIONS.DESCRIP"); associationsMapping.addReferenceKeyFieldName("EASSOCIATIONS.CUSTOMER_ID", "EVENTCUSTOMER.ID"); descriptor.addMapping(associationsMapping); OneToManyMapping ordersMapping = new OneToManyMapping(); ordersMapping.setAttributeName("orders"); ordersMapping.setReferenceClass(Order.class); ordersMapping.useBasicIndirection(); ordersMapping.addTargetForeignKeyFieldName("EVENTORDER.CUSTOMER_ID", "EVENTCUSTOMER.ID"); descriptor.addMapping(ordersMapping); AggregateObjectMapping creditMapping = new AggregateObjectMapping(); creditMapping.setAttributeName("creditCard"); creditMapping.setReferenceClass(org.eclipse.persistence.testing.models.events.CreditCard.class); creditMapping.setIsNullAllowed(true); descriptor.addMapping(creditMapping); descriptor.addDirectMapping("id", "ID"); descriptor.addDirectMapping("name", "NAME"); return descriptor; }