public void setup() {
    zeroFailed = false;
    negativeFailed = false;
    zeroOverridden = false;
    negativeOverridden = false;

    getAbstractSession().beginTransaction();
    ClassDescriptor descriptor = getSession().getClassDescriptor(Weather.class);
    idValidationOriginal = descriptor.getIdValidation();
    descriptor.setIdValidation(idValidation);
    if (keepSequencing) {
      if (descriptor.getSequence() == null) {
        // ReturningPolicyTestModel substitutes sequences for returning
        throw new TestWarningException("Cannot run test with descriptor.getSequence() == null");
      }
      if (!shouldAlwaysOverrideExistingValue) {
        if (descriptor.getSequence().shouldAcquireValueAfterInsert()) {
          throw new TestProblemException(
              "Cannot run test with keepSequencing==true and alwayOverrideExistingValueOriginal==false with Identity sequence: it should always override");
        }
      }
      shouldAlwaysOverrideExistingValueOriginal =
          descriptor.getSequence().shouldAlwaysOverrideExistingValue();
      descriptor
          .getSequence()
          .setShouldAlwaysOverrideExistingValue(shouldAlwaysOverrideExistingValue);
    } else {
      sequenceNumberField = descriptor.getSequenceNumberField();
      descriptor.setSequenceNumberField(null);
      sequenceNumberName = descriptor.getSequenceNumberName();
      descriptor.setSequenceNumberName(null);
    }
  }
 public void reset() {
   ClassDescriptor descriptor = getSession().getClassDescriptor(Weather.class);
   descriptor.setIdValidation(idValidationOriginal);
   if (keepSequencing) {
     // ReturningPolicyTestModel substitutes sequences for returning
     if (descriptor.getSequence() != null) {
       descriptor
           .getSequence()
           .setShouldAlwaysOverrideExistingValue(shouldAlwaysOverrideExistingValueOriginal);
     }
   } else {
     descriptor.setSequenceNumberField(this.sequenceNumberField);
     descriptor.setSequenceNumberName(this.sequenceNumberName);
   }
   getAbstractSession().rollbackTransaction();
   getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
 }
Example #3
0
  public static ClassDescriptor descriptor() {
    ClassDescriptor descriptor = new ClassDescriptor();

    descriptor.setJavaClass(Promoter.class);
    descriptor.setTableName("RO_PROMO");
    descriptor.addPrimaryKeyFieldName("PROMO_ID");
    descriptor.setSequenceNumberName("PROMO_SEQ");
    descriptor.setSequenceNumberFieldName("PROMO_ID");

    descriptor.addDirectMapping("id", "PROMO_ID");
    descriptor.addDirectMapping("name", "NAME");
    /*
    	// The promoter operates in a collection of countries.
    	org.eclipse.persistence.mappings.OneToManyMapping phoneNumbersMapping = new org.eclipse.persistence.mappings.OneToManyMapping() ;
    	phoneNumbersMapping.setAttributeName("phoneNumbers");
    	phoneNumbersMapping.setReferenceClass(PhoneNumber.class);
    	phoneNumbersMapping.setTargetForeignKeyFieldName("PROMO_ID");
    	phoneNumbersMapping.privateOwnedRelationship();
    //	phoneNumbersMapping.dontUseIndirection();
    	descriptor.addMapping(phoneNumbersMapping);
    */

    return descriptor;
  }