private static RelationalDescriptor commonDescriptor() {
   RelationalDescriptor descriptor = new RelationalDescriptor();
   descriptor.setJavaClass(CalendarToTSTZWithBindingTest.class);
   descriptor.setTableName("CALENDARTOTSTZ_BINDING");
   descriptor.setPrimaryKeyFieldName("TEST_ID");
   descriptor.addDirectMapping("testId", "getTestId", "setTestId", "TEST_ID");
   return descriptor;
 }
  public ClassDescriptor buildSmallProjectDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(SmallProject.class);
    descriptor.addTableName("SPROJECT");

    // Inheritance Properties.
    descriptor.getInheritancePolicy().setParentClass(Project.class);

    // Descriptor Properties.
    descriptor.setAlias("SmallProject");

    return descriptor;
  }
  protected void buildEntityMapValueDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();

    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(EntityMapValue.class);
    Vector vector = new Vector();
    vector.addElement("ENT_MAP_VALUE");
    descriptor.setTableNames(vector);
    descriptor.addPrimaryKeyFieldName("ENT_MAP_VALUE.ID");

    // SECTION: PROPERTIES
    descriptor.setIdentityMapClass(
        org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
    descriptor.setExistenceChecking("Check cache");
    descriptor.setIdentityMapSize(100);

    // SECTION: DIRECTTOFIELDMAPPING
    org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping =
        new org.eclipse.persistence.mappings.DirectToFieldMapping();
    directtofieldmapping.setAttributeName("id");
    directtofieldmapping.setIsReadOnly(false);
    directtofieldmapping.setGetMethodName("getId");
    directtofieldmapping.setSetMethodName("setId");
    directtofieldmapping.setFieldName("ENT_MAP_VALUE.ID");
    descriptor.addMapping(directtofieldmapping);

    addDescriptor(descriptor);
  }
  public ClassDescriptor buildLargeProjectDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(LargeProject.class);
    descriptor.addTableName("OTOJT_LPROJECT");

    // Inheritance Properties.
    descriptor.getInheritancePolicy().setParentClass(Project.class);
    descriptor.getInheritancePolicy().dontReadSubclassesOnQueries();

    // Descriptor Properties.
    descriptor.setAlias("OTOJT_LargeProject");

    // Cache Invalidation Policy
    // Query Manager.
    descriptor.getQueryManager().checkCacheForDoesExist();

    // Named Queries.
    // Event Manager.
    // Mappings.
    DirectToFieldMapping budgetMapping = new DirectToFieldMapping();
    budgetMapping.setAttributeName("budget");
    budgetMapping.setFieldName("OTOJT_LPROJECT.BUDGET");
    descriptor.addMapping(budgetMapping);

    DirectToFieldMapping milestoneVersionMapping = new DirectToFieldMapping();
    milestoneVersionMapping.setAttributeName("milestoneVersion");
    milestoneVersionMapping.setFieldName("OTOJT_LPROJECT.MILESTONE");
    descriptor.addMapping(milestoneVersionMapping);

    return descriptor;
  }
  protected void buildAggregateMapKeyDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.descriptorIsAggregateCollection();
    descriptor.setJavaClass(AggregateMapKey.class);

    // Descriptor Properties.
    descriptor.setAlias("AggregateMapKey");

    // Mappings.
    DirectToFieldMapping keyMapping = new DirectToFieldMapping();
    keyMapping.setAttributeName("key");
    keyMapping.setFieldName("key->DIRECT");
    keyMapping.setAttributeClassification(Integer.class);
    descriptor.addMapping(keyMapping);

    addDescriptor(descriptor);
  }
  protected void setup() {
    descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(ClassWithProblemConstructor.class);
    //   descriptor.setJavaClass(TargetInvocationWhileConstructorInstantiationOfFactoryTest.class);
    //  //no problems
    descriptor.addTableName("EMPLOYEE");
    policy = descriptor.getInstantiationPolicy();
    policy.setMethodName("method");
    policy.useFactoryInstantiationPolicy(ClassWithProblemConstructor.class, "method");

    orgIntegrityChecker = getSession().getIntegrityChecker();
    getSession().setIntegrityChecker(new IntegrityChecker()); // moved into setup
    getSession().getIntegrityChecker().dontCatchExceptions(); // moved into setup

    expectedException =
        DescriptorException.targetInvocationWhileConstructorInstantiationOfFactory(
            descriptor, new Exception());
  }
  protected void buildCharityDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();

    descriptor.setJavaClass(Charity.class);
    descriptor.setTableName("CHARITY");
    descriptor.addPrimaryKeyFieldName("CHARITY_ID");
    descriptor.setSequenceNumberName("CHARITY_SEQ");
    descriptor.setSequenceNumberFieldName("CHARITY_ID");

    descriptor.addDirectMapping("id", "CHARITY_ID");
    descriptor.addDirectMapping("name", "NAME");
    descriptor.addDirectMapping("donationsRaised", "DONATIONS_RAISED");

    addDescriptor(descriptor);
  }
  protected void buildHollywoodAgentDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();

    descriptor.setJavaClass(HollywoodAgent.class);
    descriptor.setTableName("HOLLYWOODAGENT");
    descriptor.addPrimaryKeyFieldName("HOLLYWOODAGENT_ID");
    descriptor.setSequenceNumberName("HOLLYWOODAGENT_SEQ");
    descriptor.setSequenceNumberFieldName("HOLLYWOODAGENT_ID");

    descriptor.addDirectMapping("id", "HOLLYWOODAGENT_ID");
    descriptor.addDirectMapping("name", "NAME");
    descriptor.addDirectMapping("numberOfConnections", "CONNECTIONS");

    addDescriptor(descriptor);
  }
  protected void buildDefaultReadOnlyTestClassDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(
        org.eclipse.persistence.testing.models.readonly.DefaultReadOnlyTestClass.class);
    descriptor.setTableName("DEFAULT_READ_ONLY");
    descriptor.setPrimaryKeyFieldName("DEFAULT_READ_ONLY.DATA");

    org.eclipse.persistence.mappings.DirectToFieldMapping directToFieldMapping =
        new org.eclipse.persistence.mappings.DirectToFieldMapping();
    directToFieldMapping.setAttributeName("data");
    directToFieldMapping.setFieldName("DEFAULT_READ_ONLY.DATA");
    directToFieldMapping.setGetMethodName("getData");
    directToFieldMapping.setSetMethodName("setData");
    descriptor.addMapping(directToFieldMapping);

    addDescriptor(descriptor);
    addDefaultReadOnlyClass(
        org.eclipse.persistence.testing.models.readonly.DefaultReadOnlyTestClass.class);
  }
  protected void buildReadOnlyCharityDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();

    descriptor.setJavaClass(ReadOnlyCharity.class);
    descriptor.setTableName("CHARITY");
    descriptor.addPrimaryKeyFieldName("CHARITY_ID");
    descriptor.setSequenceNumberName("CHARITY_SEQ");
    descriptor.setSequenceNumberFieldName("CHARITY_ID");

    descriptor.addDirectMapping("id", "CHARITY_ID");
    descriptor.addDirectMapping("name", "NAME");

    descriptor.setShouldBeReadOnly(true);

    addDescriptor(descriptor);
  }
 protected void setup() {
   orgIntegrityChecker = getSession().getIntegrityChecker();
   getSession().setIntegrityChecker(new IntegrityChecker()); // moved into setup
   getSession().getIntegrityChecker().dontCatchExceptions(); // moved into setup
   orgSecurityManager = System.getSecurityManager(); // security java.policy must allow full access
   System.setSecurityManager(new TestSecurityManager());
   orgDefaultUseDoPrivilegedValue = getOrgDefaultUseDoPrivilegedValue();
   PrivilegedAccessHelper.setDefaultUseDoPrivilegedValue(true);
   descriptor = new RelationalDescriptor();
   descriptor.setJavaClass(getTestClass());
 }
  /** Walk through all mapped entity's descriptors verifying that no data exists on the database */
  private static void verifyDatabaseEmpty(EntityManager em) {
    Server server = JpaHelper.getEntityManager(em).getServerSession();

    for (Iterator i = server.getDescriptors().values().iterator(); i.hasNext(); ) {
      RelationalDescriptor descriptor = (RelationalDescriptor) i.next();

      if (!descriptor.isAggregateDescriptor()) {
        ReportQuery rq = new ReportQuery(descriptor.getJavaClass(), new ExpressionBuilder());
        rq.addCount();
        rq.setShouldReturnSingleValue(true);

        int count = -1;
        try {
          count = ((Number) server.executeQuery(rq)).intValue();
        } catch (DatabaseException dbe) {

        }

        System.out.println("COUNT(" + descriptor.getAlias() + "): " + count);
      }
    }
  }
  protected void buildReadOnlyHollywoodAgentDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();

    descriptor.setJavaClass(ReadOnlyHollywoodAgent.class);
    descriptor.setTableName("HOLLYWOODAGENT");
    descriptor.addPrimaryKeyFieldName("HOLLYWOODAGENT_ID");
    descriptor.setSequenceNumberName("HOLLYWOODAGENT_SEQ");
    descriptor.setSequenceNumberFieldName("HOLLYWOODAGENT_ID");

    descriptor.addDirectMapping("id", "HOLLYWOODAGENT_ID");
    descriptor.addDirectMapping("name", "NAME");

    addDescriptor(descriptor);

    addDefaultReadOnlyClass(ReadOnlyHollywoodAgent.class);
  }
  public static RelationalDescriptor descriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();

    /* First define the class, table and descriptor properties. */
    descriptor.setJavaClass(BooleanTester.class);
    descriptor.setTableName("BOOLEANS");
    descriptor.setPrimaryKeyFieldName("NAME");

    /* Next define the attribute mappings. */
    descriptor.addDirectMapping("testName", "getTestName", "setTestName", "NAME");
    descriptor.addDirectMapping("booleanValue", "BOOLEANV");
    descriptor.addDirectMapping("booleanClassValue", "BOOLEANC");
    return descriptor;
  }
  protected void buildAEOTMValueDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();

    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(AEOTMMapValue.class);
    Vector vector = new Vector();
    vector.addElement("AE_OM_ENT_MAP_VALUE");
    descriptor.setTableNames(vector);
    descriptor.addPrimaryKeyFieldName("AE_OM_ENT_MAP_VALUE.ID");

    // SECTION: PROPERTIES
    descriptor.setIdentityMapClass(
        org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
    descriptor.setExistenceChecking("Check cache");
    descriptor.setIdentityMapSize(100);

    // SECTION: DIRECTTOFIELDMAPPING
    org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping =
        new org.eclipse.persistence.mappings.DirectToFieldMapping();
    directtofieldmapping.setAttributeName("id");
    directtofieldmapping.setIsReadOnly(false);
    directtofieldmapping.setGetMethodName("getId");
    directtofieldmapping.setSetMethodName("setId");
    directtofieldmapping.setFieldName("AE_OM_ENT_MAP_VALUE.ID");
    descriptor.addMapping(directtofieldmapping);

    OneToOneMapping holderMapping = new OneToOneMapping();
    holderMapping.setAttributeName("holder");
    holderMapping.setReferenceClass(AggregateEntity1MMapHolder.class);
    holderMapping.useBasicIndirection();
    holderMapping.setGetMethodName("getHolder");
    holderMapping.setSetMethodName("setHolder");
    holderMapping.addForeignKeyFieldName(
        "AE_OM_ENT_MAP_VALUE.HOLDER_ID", "AGG_ENT_1M_MAP_HOLDER.ID");
    descriptor.addMapping(holderMapping);

    addDescriptor(descriptor);
  }
  public ClassDescriptor buildSmallProjectDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(SmallProject.class);
    descriptor.addTableName("OTOJT_PROJECT");

    // Inheritance Properties.
    descriptor.getInheritancePolicy().setParentClass(Project.class);
    descriptor.getInheritancePolicy().dontReadSubclassesOnQueries();

    // Descriptor Properties.
    descriptor.setAlias("OTOJT_SmallProject");

    // Cache Invalidation Policy
    // Query Manager.
    descriptor.getQueryManager().checkCacheForDoesExist();

    // Named Queries.
    // Event Manager.
    return descriptor;
  }
  public ClassDescriptor buildLargeProjectDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(LargeProject.class);
    descriptor.addTableName("LPROJECT");

    // Inheritance Properties.
    descriptor.getInheritancePolicy().setParentClass(Project.class);

    // Descriptor Properties.
    descriptor.setAlias("LargeProject");

    // Mappings.
    DirectToFieldMapping budgetMapping = new DirectToFieldMapping();
    budgetMapping.setAttributeName("budget");
    budgetMapping.setFieldName("LPROJECT.BUDGET");
    descriptor.addMapping(budgetMapping);

    DirectToFieldMapping milestoneVersionMapping = new DirectToFieldMapping();
    milestoneVersionMapping.setAttributeName("milestoneVersion");
    milestoneVersionMapping.setFieldName("LPROJECT.MILESTONE");
    descriptor.addMapping(milestoneVersionMapping);

    return descriptor;
  }
  public ClassDescriptor buildEmploymentPeriodDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.descriptorIsAggregate();
    descriptor.setJavaClass(
        org.eclipse.persistence.testing.models.performance.EmploymentPeriod.class);

    // Descriptor Properties.
    descriptor.setAlias("EmploymentPeriod");

    // Mappings.
    DirectToFieldMapping endDateMapping = new DirectToFieldMapping();
    endDateMapping.setAttributeName("endDate");
    endDateMapping.setFieldName("endDate->DIRECT");
    descriptor.addMapping(endDateMapping);

    DirectToFieldMapping startDateMapping = new DirectToFieldMapping();
    startDateMapping.setAttributeName("startDate");
    startDateMapping.setFieldName("startDate->DIRECT");
    descriptor.addMapping(startDateMapping);

    return descriptor;
  }
  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 static RelationalDescriptor descriptor() {
   RelationalDescriptor descriptor = commonDescriptor();
   descriptor.addDirectMapping("calendar", "TSTZ_DATA");
   return descriptor;
 }
  public ClassDescriptor buildPojoEmployeeDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(
        org.eclipse.persistence.testing.tests.simplepojoclient.PojoEmployee.class);
    descriptor.addTableName("POJO_EMPLOYEE");
    descriptor.addPrimaryKeyFieldName("POJO_EMPLOYEE.EMP_ID");

    // Descriptor Properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.useRemoteSoftCacheWeakIdentityMap();
    descriptor.setRemoteIdentityMapSize(100);
    descriptor.setAlias("PojoEmployee");

    // Query Manager.
    descriptor.getQueryManager().checkCacheForDoesExist();

    // Event Manager.

    // Mappings.
    DirectToFieldMapping empIdMapping = new DirectToFieldMapping();
    empIdMapping.setAttributeName("empId");
    empIdMapping.setGetMethodName("getEmpId");
    empIdMapping.setSetMethodName("setEmpId");
    empIdMapping.setFieldName("POJO_EMPLOYEE.EMP_ID");
    descriptor.addMapping(empIdMapping);

    DirectToFieldMapping fNameMapping = new DirectToFieldMapping();
    fNameMapping.setAttributeName("fName");
    fNameMapping.setGetMethodName("getFName");
    fNameMapping.setSetMethodName("setFName");
    fNameMapping.setFieldName("POJO_EMPLOYEE.F_NAME");
    descriptor.addMapping(fNameMapping);

    DirectToFieldMapping genderMapping = new DirectToFieldMapping();
    genderMapping.setAttributeName("gender");
    genderMapping.setGetMethodName("getGender");
    genderMapping.setSetMethodName("setGender");
    genderMapping.setFieldName("POJO_EMPLOYEE.GENDER");
    ObjectTypeConverter genderMappingConverter = new ObjectTypeConverter();
    genderMappingConverter.addConversionValue(new Character('F'), "Female");
    genderMappingConverter.addConversionValue(new Character('M'), "Male");
    genderMapping.setConverter(genderMappingConverter);
    descriptor.addMapping(genderMapping);

    DirectToFieldMapping lNameMapping = new DirectToFieldMapping();
    lNameMapping.setAttributeName("lName");
    lNameMapping.setGetMethodName("getLName");
    lNameMapping.setSetMethodName("setLName");
    lNameMapping.setFieldName("POJO_EMPLOYEE.L_NAME");
    descriptor.addMapping(lNameMapping);

    DirectToFieldMapping managerIdMapping = new DirectToFieldMapping();
    managerIdMapping.setAttributeName("managerId");
    managerIdMapping.setGetMethodName("getManagerId");
    managerIdMapping.setSetMethodName("setManagerId");
    managerIdMapping.setFieldName("POJO_EMPLOYEE.MANAGER_ID");
    descriptor.addMapping(managerIdMapping);

    return descriptor;
  }
  /** This method was created in VisualAge. */
  public void buildPrivateConstructorDescriptor() {
    org.eclipse.persistence.descriptors.RelationalDescriptor descriptor =
        new org.eclipse.persistence.descriptors.RelationalDescriptor();

    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(
        org.eclipse.persistence.testing.tests.validation.PrivateConstructor.class);
    Vector vector = new Vector();
    vector.addElement("PRIVATE_CONST_TBL");
    descriptor.setTableNames(vector);
    descriptor.addPrimaryKeyFieldName("PRIVATE_CONST_TBL.PRIVATE_CONST_ID");

    // SECTION: PROPERTIES
    descriptor.setIdentityMapClass(
        org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
    descriptor.setSequenceNumberName("PRIVATE_CONST_ID_SEQ");
    descriptor.setSequenceNumberFieldName("PRIVATE_CONST_ID");
    descriptor.setExistenceChecking("Check cache");
    descriptor.setIdentityMapSize(100);

    // SECTION: DIRECTTOFIELDMAPPING
    org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping =
        new org.eclipse.persistence.mappings.DirectToFieldMapping();
    directtofieldmapping.setAttributeName("id");
    directtofieldmapping.setIsReadOnly(false);
    directtofieldmapping.setFieldName("PRIVATE_CONST_TBL.PRIVATE_CONST_ID");
    descriptor.addMapping(directtofieldmapping);

    // SECTION: COPY POLICY
    descriptor.createCopyPolicy("constructor");

    // SECTION: INSTANTIATION POLICY
    descriptor.createInstantiationPolicy("constructor");

    addDescriptor(descriptor);
  }
  protected void buildEntityEntity1MMapHolderDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();

    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(EntityEntity1MMapHolder.class);
    Vector vector = new Vector();
    vector.addElement("ENT_ENT_1M_MAP_HOLDER");
    descriptor.setTableNames(vector);
    descriptor.addPrimaryKeyFieldName("ENT_ENT_1M_MAP_HOLDER.ID");

    // SECTION: PROPERTIES
    descriptor.setIdentityMapClass(
        org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
    descriptor.setExistenceChecking("Check cache");
    descriptor.setIdentityMapSize(100);
    descriptor.setSequenceNumberName("ENT_ENT_1M_MAP_HOLDER_ID");
    descriptor.setSequenceNumberFieldName("ID");

    // SECTION: DIRECTTOFIELDMAPPING
    org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping =
        new org.eclipse.persistence.mappings.DirectToFieldMapping();
    directtofieldmapping.setAttributeName("id");
    directtofieldmapping.setIsReadOnly(false);
    directtofieldmapping.setGetMethodName("getId");
    directtofieldmapping.setSetMethodName("setId");
    directtofieldmapping.setFieldName("ENT_ENT_1M_MAP_HOLDER.ID");
    descriptor.addMapping(directtofieldmapping);

    OneToManyMapping mapMapping = new OneToManyMapping();
    mapMapping.setAttributeName("entityToEntityMap");
    mapMapping.setReferenceClass(EEOTMMapValue.class);
    mapMapping.setIndirectionPolicy(new TransparentIndirectionPolicy());
    mapMapping.setGetMethodName("getEntityToEntityMap");
    mapMapping.setSetMethodName("setEntityToEntityMap");
    mapMapping.addTargetForeignKeyFieldName(
        "EE_OM_ENT_MAP_VALUE.HOLDER_ID", "ENT_ENT_1M_MAP_HOLDER.ID");

    org.eclipse.persistence.mappings.OneToOneMapping keyMapping =
        new org.eclipse.persistence.mappings.OneToOneMapping();
    keyMapping.setReferenceClass(EntityMapKey.class);
    keyMapping.dontUseIndirection();
    keyMapping.addForeignKeyFieldName("EE_OM_ENT_MAP_VALUE.KEY_ID", "ENT_MAP_KEY.ID");
    keyMapping.setDescriptor(descriptor);

    MappedKeyMapContainerPolicy policy = new MappedKeyMapContainerPolicy(IndirectMap.class);
    policy.setKeyMapping(keyMapping);
    policy.setValueMapping(mapMapping);
    mapMapping.setContainerPolicy(policy);

    descriptor.addMapping(mapMapping);

    addDescriptor(descriptor);
  }
  protected void buildDirectDirectMapHolderDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();

    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(DirectDirectMapHolder.class);
    Vector vector = new Vector();
    vector.addElement("DIR_DIR_MAP_HOLDER");
    descriptor.setTableNames(vector);
    descriptor.addPrimaryKeyFieldName("DIR_DIR_MAP_HOLDER.ID");

    // SECTION: PROPERTIES
    descriptor.setIdentityMapClass(
        org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
    descriptor.setExistenceChecking("Check cache");
    descriptor.setIdentityMapSize(100);
    descriptor.setSequenceNumberName("DIR_DIR_MAP_HOLDER_ID");
    descriptor.setSequenceNumberFieldName("ID");

    // SECTION: DIRECTTOFIELDMAPPING
    org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping =
        new org.eclipse.persistence.mappings.DirectToFieldMapping();
    directtofieldmapping.setAttributeName("id");
    directtofieldmapping.setIsReadOnly(false);
    directtofieldmapping.setGetMethodName("getId");
    directtofieldmapping.setSetMethodName("setId");
    directtofieldmapping.setFieldName("DIR_DIR_MAP_HOLDER.ID");
    descriptor.addMapping(directtofieldmapping);

    DirectMapMapping directMapMapping = new DirectMapMapping();
    directMapMapping.setAttributeName("directToDirectMap");
    directMapMapping.setReferenceTableName("DIR_DIR_MAP_REL");
    directMapMapping.setDirectFieldName("DIR_DIR_MAP_REL.MAP_VALUE");
    directMapMapping.addReferenceKeyFieldName("DIR_DIR_MAP_REL.HOLDER_ID", "DIR_DIR_MAP_HOLDER.ID");
    directMapMapping.setDirectFieldClassification(Integer.class);
    directMapMapping.setIndirectionPolicy(new TransparentIndirectionPolicy());

    org.eclipse.persistence.mappings.DirectToFieldMapping keyMapping =
        new org.eclipse.persistence.mappings.DirectToFieldMapping();
    keyMapping.setFieldName("DIR_DIR_MAP_REL.MAP_KEY");
    keyMapping.setAttributeClassification(Integer.class);
    keyMapping.setDescriptor(descriptor);

    MappedKeyMapContainerPolicy policy = new MappedKeyMapContainerPolicy(IndirectMap.class);
    policy.setKeyMapping(keyMapping);
    policy.setValueMapping(directMapMapping);
    directMapMapping.setContainerPolicy(policy);

    descriptor.addMapping(directMapMapping);

    addDescriptor(descriptor);
  }
  public ClassDescriptor buildChildDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(Child.class);
    descriptor.addTableName("OTOJT_CHILD");
    descriptor.addPrimaryKeyFieldName("OTOJT_CHILD.CHILD_ID");

    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(50);
    descriptor.setSequenceNumberFieldName("OTOJT_CHILD.CHILD_ID");
    descriptor.setSequenceNumberName("OTOJT_CHILD_SEQ");
    descriptor.setAlias("OTOJT_Child");

    // Query Manager.
    descriptor.getQueryManager().checkCacheForDoesExist();

    // Mappings.
    DirectToFieldMapping firstNameMapping = new DirectToFieldMapping();
    firstNameMapping.setAttributeName("firstName");
    firstNameMapping.setFieldName("F_NAME");
    firstNameMapping.setNullValue("");
    descriptor.addMapping(firstNameMapping);

    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("CHILD_ID");
    descriptor.addMapping(idMapping);

    DirectToFieldMapping lastNameMapping = new DirectToFieldMapping();
    lastNameMapping.setAttributeName("lastName");
    lastNameMapping.setFieldName("L_NAME");
    lastNameMapping.setNullValue("");
    descriptor.addMapping(lastNameMapping);

    DirectToFieldMapping genderMapping = new DirectToFieldMapping();
    genderMapping.setAttributeName("gender");
    genderMapping.setFieldName("GENDER");
    ObjectTypeConverter genderMappingConverter = new ObjectTypeConverter();
    genderMappingConverter.addConversionValue("F", "Female");
    genderMappingConverter.addConversionValue("M", "Male");
    genderMapping.setConverter(genderMappingConverter);
    descriptor.addMapping(genderMapping);

    DirectToFieldMapping birthdayMapping = new DirectToFieldMapping();
    birthdayMapping.setAttributeName("birthday");
    birthdayMapping.setFieldName("BIRTHDAY");
    descriptor.addMapping(birthdayMapping);

    OneToOneMapping parentMapping = new OneToOneMapping();
    parentMapping.setAttributeName("parent");
    parentMapping.setReferenceClass(Employee.class);
    parentMapping.dontUseIndirection();
    parentMapping.setRelationTableMechanism(new RelationTableMechanism());
    parentMapping.getRelationTableMechanism().setRelationTableName("OTOJT_CHILD_PARENT");
    parentMapping
        .getRelationTableMechanism()
        .addSourceRelationKeyFieldName("OTOJT_CHILD_PARENT.CHILD_ID", "OTOJT_CHILD.CHILD_ID");
    parentMapping
        .getRelationTableMechanism()
        .addTargetRelationKeyFieldName("OTOJT_CHILD_PARENT.EMP_ID", "OTOJT_EMPLOYEE.EMP_ID");
    //        parentMapping.addForeignKeyFieldName("OTOJT_CHILD.PARENT_EMP_ID",
    // "OTOJT_EMPLOYEE.EMP_ID");
    parentMapping.readOnly();
    descriptor.addMapping(parentMapping);

    return descriptor;
  }
  protected void buildAggregateEntityMapHolderDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();

    // SECTION: DESCRIPTOR
    descriptor.setJavaClass(AggregateEntityMapHolder.class);
    Vector vector = new Vector();
    vector.addElement("AGG_ENT_MAP_HOLDER");
    descriptor.setTableNames(vector);
    descriptor.addPrimaryKeyFieldName("AGG_ENT_MAP_HOLDER.ID");

    // SECTION: PROPERTIES
    descriptor.setIdentityMapClass(
        org.eclipse.persistence.internal.identitymaps.FullIdentityMap.class);
    descriptor.setExistenceChecking("Check cache");
    descriptor.setIdentityMapSize(100);
    descriptor.setSequenceNumberName("AGG_ENT_MAP_HOLDER_ID");
    descriptor.setSequenceNumberFieldName("ID");

    // SECTION: DIRECTTOFIELDMAPPING
    org.eclipse.persistence.mappings.DirectToFieldMapping directtofieldmapping =
        new org.eclipse.persistence.mappings.DirectToFieldMapping();
    directtofieldmapping.setAttributeName("id");
    directtofieldmapping.setIsReadOnly(false);
    directtofieldmapping.setGetMethodName("getId");
    directtofieldmapping.setSetMethodName("setId");
    directtofieldmapping.setFieldName("AGG_ENT_MAP_HOLDER.ID");
    descriptor.addMapping(directtofieldmapping);

    ManyToManyMapping mapMapping = new ManyToManyMapping();
    mapMapping.setAttributeName("aggregateToEntityMap");
    mapMapping.setIndirectionPolicy(new TransparentIndirectionPolicy());
    mapMapping.setReferenceClass(EntityMapValue.class);
    mapMapping.setRelationTableName("AGG_ENT_MAP_REL");
    mapMapping.setGetMethodName("getAggregateToEntityMap");
    mapMapping.setSetMethodName("setAggregateToEntityMap");
    mapMapping.addSourceRelationKeyFieldName("AGG_ENT_MAP_REL.HOLDER_ID", "AGG_ENT_MAP_HOLDER.ID");
    mapMapping.addTargetRelationKeyFieldName("AGG_ENT_MAP_REL.VALUE_ID", "ENT_MAP_VALUE.ID");

    AggregateObjectMapping keyMapping = new AggregateObjectMapping();
    keyMapping.setReferenceClass(AggregateMapKey.class);
    keyMapping.addFieldNameTranslation("AGG_ENT_MAP_REL.MAP_KEY", "key->DIRECT");
    keyMapping.setDescriptor(descriptor);

    MappedKeyMapContainerPolicy policy = new MappedKeyMapContainerPolicy(IndirectMap.class);
    policy.setKeyMapping(keyMapping);
    policy.setValueMapping(mapMapping);
    mapMapping.setContainerPolicy(policy);

    descriptor.addMapping(mapMapping);

    addDescriptor(descriptor);
  }
  public ClassDescriptor buildAddressDescriptor() {
    RelationalDescriptor descriptor = new RelationalDescriptor();
    descriptor.setJavaClass(org.eclipse.persistence.testing.models.performance.Address.class);
    descriptor.addTableName("ADDRESS");
    descriptor.addPrimaryKeyFieldName("ADDRESS.ADDRESS_ID");

    // Descriptor Properties.
    descriptor.useSoftCacheWeakIdentityMap();
    descriptor.setIdentityMapSize(100);
    descriptor.setSequenceNumberFieldName("ADDRESS.ADDRESS_ID");
    descriptor.setSequenceNumberName("ADDRESS_SEQ");
    descriptor.setAlias("Address");

    // Mappings.
    DirectToFieldMapping cityMapping = new DirectToFieldMapping();
    cityMapping.setAttributeName("city");
    cityMapping.setFieldName("ADDRESS.CITY");
    descriptor.addMapping(cityMapping);

    DirectToFieldMapping countryMapping = new DirectToFieldMapping();
    countryMapping.setAttributeName("country");
    countryMapping.setFieldName("ADDRESS.COUNTRY");
    descriptor.addMapping(countryMapping);

    DirectToFieldMapping idMapping = new DirectToFieldMapping();
    idMapping.setAttributeName("id");
    idMapping.setFieldName("ADDRESS.ADDRESS_ID");
    descriptor.addMapping(idMapping);

    DirectToFieldMapping postalCodeMapping = new DirectToFieldMapping();
    postalCodeMapping.setAttributeName("postalCode");
    postalCodeMapping.setFieldName("ADDRESS.P_CODE");
    descriptor.addMapping(postalCodeMapping);

    DirectToFieldMapping provinceMapping = new DirectToFieldMapping();
    provinceMapping.setAttributeName("province");
    provinceMapping.setFieldName("ADDRESS.PROVINCE");
    descriptor.addMapping(provinceMapping);

    DirectToFieldMapping streetMapping = new DirectToFieldMapping();
    streetMapping.setAttributeName("street");
    streetMapping.setFieldName("ADDRESS.STREET");
    descriptor.addMapping(streetMapping);

    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;
  }
示例#30
0
  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;
  }