public ClassDescriptor buildProjectDescriptor() { RelationalDescriptor descriptor = new RelationalDescriptor(); descriptor.setJavaClass(Project.class); descriptor.addTableName("PROJECT"); descriptor.addPrimaryKeyFieldName("PROJECT.PROJ_ID"); // Inheritance Properties. descriptor.getInheritancePolicy().setClassIndicatorFieldName("PROJECT.PROJ_TYPE"); descriptor.getInheritancePolicy().addClassIndicator(SmallProject.class, "S"); descriptor.getInheritancePolicy().addClassIndicator(LargeProject.class, "L"); // Descriptor Properties. descriptor.useSoftCacheWeakIdentityMap(); descriptor.setIdentityMapSize(100); descriptor.setSequenceNumberFieldName("PROJECT.PROJ_ID"); descriptor.setSequenceNumberName("PROJ_SEQ"); VersionLockingPolicy lockingPolicy = new VersionLockingPolicy(); lockingPolicy.setWriteLockFieldName("PROJECT.VERSION"); lockingPolicy.storeInObject(); descriptor.setOptimisticLockingPolicy(lockingPolicy); descriptor.setAlias("Project"); // Mappings. DirectToFieldMapping descriptionMapping = new DirectToFieldMapping(); descriptionMapping.setAttributeName("description"); descriptionMapping.setFieldName("PROJECT.DESCRIP"); descriptionMapping.setNullValue(""); descriptor.addMapping(descriptionMapping); DirectToFieldMapping idMapping = new DirectToFieldMapping(); idMapping.setAttributeName("id"); idMapping.setFieldName("PROJECT.PROJ_ID"); descriptor.addMapping(idMapping); DirectToFieldMapping versionMapping = new DirectToFieldMapping(); versionMapping.setAttributeName("version"); versionMapping.setFieldName("PROJECT.VERSION"); descriptor.addMapping(versionMapping); DirectToFieldMapping nameMapping = new DirectToFieldMapping(); nameMapping.setAttributeName("name"); nameMapping.setFieldName("PROJECT.PROJ_NAME"); nameMapping.setNullValue(""); descriptor.addMapping(nameMapping); OneToOneMapping teamLeaderMapping = new OneToOneMapping(); teamLeaderMapping.setAttributeName("teamLeaderHolder"); teamLeaderMapping.setReferenceClass(Employee.class); teamLeaderMapping.useBasicIndirection(); teamLeaderMapping.addForeignKeyFieldName("PROJECT.LEADER_ID", "EMPLOYEE.EMP_ID"); descriptor.addMapping(teamLeaderMapping); return descriptor; }
public ClassDescriptor buildPhoneNumberDescriptor() { RelationalDescriptor descriptor = new RelationalDescriptor(); descriptor.setJavaClass(PhoneNumber.class); descriptor.addTableName("PHONE"); descriptor.addPrimaryKeyFieldName("PHONE.PHONE_ID"); // Descriptor Properties. descriptor.useSoftCacheWeakIdentityMap(); descriptor.setIdentityMapSize(100); descriptor.setSequenceNumberFieldName("PHONE.PHONE_ID"); descriptor.setSequenceNumberName("PHONE_SEQ"); descriptor.setAlias("PhoneNumber"); // Query keys. descriptor.addDirectQueryKey("id", "PHONE.EMP_ID"); // Mappings. DirectToFieldMapping idMapping = new DirectToFieldMapping(); idMapping.setAttributeName("id"); idMapping.setFieldName("PHONE.PHONE_ID"); descriptor.addMapping(idMapping); DirectToFieldMapping areaCodeMapping = new DirectToFieldMapping(); areaCodeMapping.setAttributeName("areaCode"); areaCodeMapping.setFieldName("PHONE.AREA_CODE"); descriptor.addMapping(areaCodeMapping); DirectToFieldMapping numberMapping = new DirectToFieldMapping(); numberMapping.setAttributeName("number"); numberMapping.setFieldName("PHONE.P_NUMBER"); descriptor.addMapping(numberMapping); DirectToFieldMapping typeMapping = new DirectToFieldMapping(); typeMapping.setAttributeName("type"); typeMapping.setFieldName("PHONE.TYPE"); descriptor.addMapping(typeMapping); OneToOneMapping ownerMapping = new OneToOneMapping(); ownerMapping.setAttributeName("ownerHolder"); ownerMapping.setReferenceClass(Employee.class); ownerMapping.useBasicIndirection(); ownerMapping.addForeignKeyFieldName("PHONE.EMP_ID", "EMPLOYEE.EMP_ID"); descriptor.addMapping(ownerMapping); return descriptor; }
public ClassDescriptor buildEmployeeDescriptor() { RelationalDescriptor descriptor = new RelationalDescriptor(); descriptor.setJavaClass(Employee.class); descriptor.addTableName("EMPLOYEE"); descriptor.addPrimaryKeyFieldName("EMPLOYEE.EMP_ID"); // Descriptor Properties. descriptor.useSoftCacheWeakIdentityMap(); descriptor.setIdentityMapSize(100); descriptor.setSequenceNumberFieldName("EMPLOYEE.EMP_ID"); descriptor.setSequenceNumberName("EMP_SEQ"); VersionLockingPolicy lockingPolicy = new VersionLockingPolicy(); lockingPolicy.setWriteLockFieldName("EMPLOYEE.VERSION"); lockingPolicy.storeInObject(); descriptor.setOptimisticLockingPolicy(lockingPolicy); descriptor.setAlias("Employee"); // Mappings. DirectToFieldMapping firstNameMapping = new DirectToFieldMapping(); firstNameMapping.setAttributeName("firstName"); firstNameMapping.setFieldName("EMPLOYEE.F_NAME"); firstNameMapping.setNullValue(""); descriptor.addMapping(firstNameMapping); DirectToFieldMapping idMapping = new DirectToFieldMapping(); idMapping.setAttributeName("id"); idMapping.setFieldName("EMPLOYEE.EMP_ID"); descriptor.addMapping(idMapping); DirectToFieldMapping versionMapping = new DirectToFieldMapping(); versionMapping.setAttributeName("version"); versionMapping.setFieldName("EMPLOYEE.VERSION"); descriptor.addMapping(versionMapping); DirectToFieldMapping lastNameMapping = new DirectToFieldMapping(); lastNameMapping.setAttributeName("lastName"); lastNameMapping.setFieldName("EMPLOYEE.L_NAME"); lastNameMapping.setNullValue(""); descriptor.addMapping(lastNameMapping); DirectToFieldMapping salaryMapping = new DirectToFieldMapping(); salaryMapping.setAttributeName("salary"); salaryMapping.setFieldName("EMPLOYEE.SALARY"); descriptor.addMapping(salaryMapping); DirectToFieldMapping genderMapping = new DirectToFieldMapping(); genderMapping.setAttributeName("gender"); genderMapping.setFieldName("EMPLOYEE.GENDER"); descriptor.addMapping(genderMapping); AggregateObjectMapping periodMapping = new AggregateObjectMapping(); periodMapping.setAttributeName("period"); periodMapping.setReferenceClass( org.eclipse.persistence.testing.models.performance.EmploymentPeriod.class); periodMapping.setIsNullAllowed(true); periodMapping.addFieldNameTranslation("EMPLOYEE.END_DATE", "endDate->DIRECT"); periodMapping.addFieldNameTranslation("EMPLOYEE.START_DATE", "startDate->DIRECT"); descriptor.addMapping(periodMapping); OneToOneMapping addressMapping = new OneToOneMapping(); addressMapping.setAttributeName("address"); addressMapping.setGetMethodName("getAddressHolder"); addressMapping.setSetMethodName("setAddressHolder"); addressMapping.setReferenceClass( org.eclipse.persistence.testing.models.performance.Address.class); addressMapping.useBasicIndirection(); addressMapping.privateOwnedRelationship(); addressMapping.addForeignKeyFieldName("EMPLOYEE.ADDR_ID", "ADDRESS.ADDRESS_ID"); descriptor.addMapping(addressMapping); OneToOneMapping managerMapping = new OneToOneMapping(); managerMapping.setAttributeName("manager"); managerMapping.setGetMethodName("getManagerHolder"); managerMapping.setSetMethodName("setManagerHolder"); managerMapping.setReferenceClass(Employee.class); managerMapping.useBasicIndirection(); managerMapping.addForeignKeyFieldName("EMPLOYEE.MANAGER_ID", "EMPLOYEE.EMP_ID"); descriptor.addMapping(managerMapping); OneToManyMapping managedEmployeesMapping = new OneToManyMapping(); managedEmployeesMapping.setAttributeName("managedEmployees"); managedEmployeesMapping.setReferenceClass(Employee.class); managedEmployeesMapping.useTransparentSet(); managedEmployeesMapping.addTargetForeignKeyFieldName("EMPLOYEE.MANAGER_ID", "EMPLOYEE.EMP_ID"); descriptor.addMapping(managedEmployeesMapping); OneToManyMapping phoneNumbersMapping = new OneToManyMapping(); phoneNumbersMapping.setAttributeName("phoneNumbers"); phoneNumbersMapping.setReferenceClass(PhoneNumber.class); phoneNumbersMapping.useTransparentSet(); phoneNumbersMapping.privateOwnedRelationship(); phoneNumbersMapping.addTargetForeignKeyFieldName("PHONE.EMP_ID", "EMPLOYEE.EMP_ID"); descriptor.addMapping(phoneNumbersMapping); ManyToManyMapping projectsMapping = new ManyToManyMapping(); projectsMapping.setAttributeName("projects"); projectsMapping.setReferenceClass(Project.class); projectsMapping.useTransparentSet(); projectsMapping.setRelationTableName("PROJ_EMP"); projectsMapping.addSourceRelationKeyFieldName("PROJ_EMP.EMP_ID", "EMPLOYEE.EMP_ID"); projectsMapping.addTargetRelationKeyFieldName("PROJ_EMP.PROJ_ID", "PROJECT.PROJ_ID"); descriptor.addMapping(projectsMapping); return descriptor; }
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; }
/** * TopLink generated method. <b>WARNING</b>: This code was generated by an automated tool. Any * changes will be lost when the code is re-generated */ protected void buildActorDescriptor() { RelationalDescriptor descriptor = new RelationalDescriptor(); // SECTION: DESCRIPTOR descriptor.setJavaClass(org.eclipse.persistence.testing.models.readonly.Actor.class); Vector vector = new Vector(); vector.addElement("RO_ACTOR"); descriptor.setTableNames(vector); descriptor.addPrimaryKeyFieldName("RO_ACTOR.ACT_ID"); // SECTION: PROPERTIES descriptor.setIdentityMapClass( org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class); descriptor.setSequenceNumberName("SEQ"); descriptor.setSequenceNumberFieldName("ACT_ID"); descriptor.setExistenceChecking("Check cache"); descriptor.setIdentityMapSize(100); // SECTION: COPY POLICY descriptor.createCopyPolicy("constructor"); // SECTION: INSTANTIATION POLICY descriptor.createInstantiationPolicy("constructor"); // SECTION: DIRECTTOFIELDMAPPING org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping = new org.eclipse.persistence.mappings.DirectToFieldMapping(); directtofieldmapping.setAttributeName("id"); directtofieldmapping.setIsReadOnly(false); directtofieldmapping.setFieldName("RO_ACTOR.ACT_ID"); descriptor.addMapping(directtofieldmapping); // SECTION: DIRECTTOFIELDMAPPING org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping1 = new org.eclipse.persistence.mappings.DirectToFieldMapping(); directtofieldmapping1.setAttributeName("minimumSalary"); directtofieldmapping1.setIsReadOnly(false); directtofieldmapping1.setFieldName("RO_ACTOR.MIN_SAL"); descriptor.addMapping(directtofieldmapping1); // SECTION: DIRECTTOFIELDMAPPING org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping2 = new org.eclipse.persistence.mappings.DirectToFieldMapping(); directtofieldmapping2.setAttributeName("name"); directtofieldmapping2.setIsReadOnly(false); directtofieldmapping2.setFieldName("RO_ACTOR.ACT_NAME"); descriptor.addMapping(directtofieldmapping2); // SECTION: MANYTOMANYMAPPING org.eclipse.persistence.mappings.ManyToManyMapping manytomanymapping = new org.eclipse.persistence.mappings.ManyToManyMapping(); manytomanymapping.setAttributeName("movies"); manytomanymapping.setIsReadOnly(true); manytomanymapping.setUsesIndirection(false); manytomanymapping.setReferenceClass( org.eclipse.persistence.testing.models.readonly.Movie.class); manytomanymapping.setIsPrivateOwned(false); manytomanymapping.setRelationTableName("ACT_MOV"); manytomanymapping.addSourceRelationKeyFieldName("ACT_MOV.ACT_ID", "RO_ACTOR.ACT_ID"); manytomanymapping.addTargetRelationKeyFieldName("ACT_MOV.MOV_ID", "RO_MOVIE.MOV_ID"); descriptor.addMapping(manytomanymapping); // ManyToManyMapping: charities ManyToManyMapping charitiesMapping = new ManyToManyMapping(); charitiesMapping.setAttributeName("charities"); charitiesMapping.setIsReadOnly(false); charitiesMapping.setUsesIndirection(false); charitiesMapping.setReferenceClass(ReadOnlyCharity.class); charitiesMapping.setIsPrivateOwned(false); charitiesMapping.setRelationTableName("ACT_CHA"); charitiesMapping.setSourceRelationKeyFieldName("ACT_ID"); charitiesMapping.setTargetRelationKeyFieldName("CHARITY_ID"); descriptor.addMapping(charitiesMapping); // OneToOneMapping: hollywoodAgent OneToOneMapping hollywoodAgentMapping = new OneToOneMapping(); hollywoodAgentMapping.setAttributeName("hollywoodAgent"); hollywoodAgentMapping.setIsReadOnly(false); hollywoodAgentMapping.setUsesIndirection(false); hollywoodAgentMapping.setReferenceClass(ReadOnlyHollywoodAgent.class); hollywoodAgentMapping.setIsPrivateOwned(false); hollywoodAgentMapping.addForeignKeyFieldName("HOLLYWOODAGENT_ID", "HOLLYWOODAGENT_ID"); descriptor.addMapping(hollywoodAgentMapping); addDescriptor(descriptor); }