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(); }