Program: 68687
Project: 68687
Buggy source:
/** 
 * INTERNAL: Process the sequencing information.
 */
protected void processSequencing(){
  if (!m_generatedValues.isEmpty()) {
    DatasourceLogin login=m_session.getProject().getLogin();
    Sequence defaultAutoSequence=null;
    TableSequence defaultTableSequence=new TableSequence(MetadataConstants.DEFAULT_TABLE_GENERATOR);
    NativeSequence defaultObjectNativeSequence=new NativeSequence(MetadataConstants.DEFAULT_SEQUENCE_GENERATOR,false);
    NativeSequence defaultIdentityNativeSequence=new NativeSequence(MetadataConstants.DEFAULT_IDENTITY_GENERATOR,1,true);
    Hashtable<String,Sequence> sequences=new Hashtable<String,Sequence>();
    for (    SequenceGeneratorMetadata sequenceGenerator : m_sequenceGenerators.values()) {
      String sequenceGeneratorName=sequenceGenerator.getName();
      String seqName;
      if (sequenceGenerator.getSequenceName() != null && (!sequenceGenerator.getSequenceName().equals("String_Node_Str"))) {
        seqName=sequenceGenerator.getSequenceName();
      }
 else {
        seqName=sequenceGeneratorName;
      }
      Integer allocationSize=sequenceGenerator.getAllocationSize();
      if (allocationSize == null) {
        allocationSize=new Integer(50);
      }
      NativeSequence sequence=new NativeSequence(seqName,allocationSize,false);
      sequences.put(sequenceGeneratorName,sequence);
      if (sequenceGeneratorName.equals(MetadataConstants.DEFAULT_AUTO_GENERATOR)) {
        defaultAutoSequence=sequence;
      }
 else       if (sequenceGeneratorName.equals(MetadataConstants.DEFAULT_SEQUENCE_GENERATOR)) {
        defaultObjectNativeSequence=sequence;
      }
    }
    for (    TableGeneratorMetadata tableGenerator : m_tableGenerators.values()) {
      String tableGeneratorName=tableGenerator.getGeneratorName();
      String seqName;
      if (tableGenerator.getPkColumnValue() != null && (!tableGenerator.getPkColumnValue().equals("String_Node_Str"))) {
        seqName=tableGenerator.getPkColumnValue();
      }
 else {
        seqName=tableGeneratorName;
      }
      Integer allocationSize=tableGenerator.getAllocationSize();
      if (allocationSize == null) {
        allocationSize=new Integer(50);
      }
      Integer initialValue=tableGenerator.getInitialValue();
      if (initialValue == null) {
        initialValue=new Integer(0);
      }
      TableSequence sequence=new TableSequence(seqName,allocationSize,initialValue);
      sequences.put(tableGeneratorName,sequence);
      sequence.setTable(tableGenerator.getDatabaseTable());
      if (tableGenerator.getPkColumnName() != null && (!tableGenerator.getPkColumnName().equals("String_Node_Str"))) {
        sequence.setNameFieldName(tableGenerator.getPkColumnName());
      }
      if (tableGenerator.getValueColumnName() != null && (!tableGenerator.getValueColumnName().equals("String_Node_Str"))) {
        sequence.setCounterFieldName(tableGenerator.getValueColumnName());
      }
      if (tableGeneratorName.equals(MetadataConstants.DEFAULT_AUTO_GENERATOR)) {
        defaultAutoSequence=sequence;
      }
 else       if (tableGeneratorName.equals(MetadataConstants.DEFAULT_TABLE_GENERATOR)) {
        defaultTableSequence=sequence;
      }
    }
    boolean usesAuto=false;
    for (    Class entityClass : m_generatedValues.keySet()) {
      MetadataDescriptor descriptor=m_allAccessors.get(entityClass.getName()).getDescriptor();
      GeneratedValueMetadata generatedValue=m_generatedValues.get(entityClass);
      String generatorName=generatedValue.getGenerator();
      if (generatorName == null) {
        generatorName="String_Node_Str";
      }
      Sequence sequence=null;
      if (!generatorName.equals("String_Node_Str")) {
        sequence=sequences.get(generatorName);
      }
      if (sequence == null) {
        GenerationType strategy=generatedValue.getStrategy();
        if (strategy == null || strategy.equals(GenerationType.AUTO)) {
          usesAuto=true;
        }
 else         if (strategy.equals(GenerationType.TABLE)) {
          if (generatorName.equals("String_Node_Str")) {
            sequence=defaultTableSequence;
          }
 else {
            sequence=(Sequence)defaultTableSequence.clone();
            sequence.setName(generatorName);
          }
        }
 else         if (strategy.equals(GenerationType.SEQUENCE)) {
          if (generatorName.equals("String_Node_Str")) {
            sequence=defaultObjectNativeSequence;
          }
 else {
            sequence=(Sequence)defaultObjectNativeSequence.clone();
            sequence.setName(generatorName);
          }
        }
 else         if (strategy.equals(GenerationType.IDENTITY)) {
          if (generatorName.equals("String_Node_Str")) {
            sequence=defaultIdentityNativeSequence;
          }
 else {
            sequence=(Sequence)defaultIdentityNativeSequence.clone();
            sequence.setName(generatorName);
          }
        }
      }
      if (sequence != null) {
        descriptor.setSequenceNumberName(sequence.getName());
        login.addSequence(sequence);
      }
 else {
        String seqName;
        if (generatorName.equals("String_Node_Str")) {
          if (defaultAutoSequence != null) {
            seqName=defaultAutoSequence.getName();
          }
 else {
            seqName=MetadataConstants.DEFAULT_AUTO_GENERATOR;
          }
        }
 else {
          seqName=generatorName;
        }
        descriptor.setSequenceNumberName(seqName);
      }
    }
    if (usesAuto) {
      if (defaultAutoSequence != null) {
        login.setDefaultSequence(defaultAutoSequence);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL: Process the sequencing information.
 */
protected void processSequencing(){
  if (!m_generatedValues.isEmpty()) {
    DatasourceLogin login=m_session.getProject().getLogin();
    Sequence defaultAutoSequence=null;
    TableSequence defaultTableSequence=new TableSequence(MetadataConstants.DEFAULT_TABLE_GENERATOR);
    NativeSequence defaultObjectNativeSequence=new NativeSequence(MetadataConstants.DEFAULT_SEQUENCE_GENERATOR,false);
    NativeSequence defaultIdentityNativeSequence=new NativeSequence(MetadataConstants.DEFAULT_IDENTITY_GENERATOR,1,true);
    Hashtable<String,Sequence> sequences=new Hashtable<String,Sequence>();
    for (    SequenceGeneratorMetadata sequenceGenerator : m_sequenceGenerators.values()) {
      String sequenceGeneratorName=sequenceGenerator.getName();
      String seqName;
      if (sequenceGenerator.getSequenceName() != null && (!sequenceGenerator.getSequenceName().equals("String_Node_Str"))) {
        seqName=sequenceGenerator.getSequenceName();
      }
 else {
        seqName=sequenceGeneratorName;
      }
      Integer allocationSize=sequenceGenerator.getAllocationSize();
      if (allocationSize == null) {
        allocationSize=new Integer(50);
      }
      NativeSequence sequence=new NativeSequence(seqName,allocationSize,false);
      sequences.put(sequenceGeneratorName,sequence);
      if (sequenceGeneratorName.equals(MetadataConstants.DEFAULT_AUTO_GENERATOR)) {
        defaultAutoSequence=sequence;
      }
 else       if (sequenceGeneratorName.equals(MetadataConstants.DEFAULT_SEQUENCE_GENERATOR)) {
        defaultObjectNativeSequence=sequence;
      }
    }
    for (    TableGeneratorMetadata tableGenerator : m_tableGenerators.values()) {
      String tableGeneratorName=tableGenerator.getGeneratorName();
      String seqName;
      if (tableGenerator.getPkColumnValue() != null && (!tableGenerator.getPkColumnValue().equals("String_Node_Str"))) {
        seqName=tableGenerator.getPkColumnValue();
      }
 else {
        seqName=tableGeneratorName;
      }
      Integer allocationSize=tableGenerator.getAllocationSize();
      if (allocationSize == null) {
        allocationSize=new Integer(50);
      }
      Integer initialValue=tableGenerator.getInitialValue();
      if (initialValue == null) {
        initialValue=new Integer(0);
      }
      TableSequence sequence=new TableSequence(seqName,allocationSize,initialValue);
      sequences.put(tableGeneratorName,sequence);
      sequence.setTable(tableGenerator.getDatabaseTable());
      if (tableGenerator.getPkColumnName() != null && (!tableGenerator.getPkColumnName().equals("String_Node_Str"))) {
        sequence.setNameFieldName(tableGenerator.getPkColumnName());
      }
      if (tableGenerator.getValueColumnName() != null && (!tableGenerator.getValueColumnName().equals("String_Node_Str"))) {
        sequence.setCounterFieldName(tableGenerator.getValueColumnName());
      }
      if (tableGeneratorName.equals(MetadataConstants.DEFAULT_AUTO_GENERATOR)) {
        defaultAutoSequence=sequence;
      }
 else       if (tableGeneratorName.equals(MetadataConstants.DEFAULT_TABLE_GENERATOR)) {
        defaultTableSequence=sequence;
      }
    }
    boolean usesAuto=false;
    for (    Class entityClass : m_generatedValues.keySet()) {
      MetadataDescriptor descriptor=m_allAccessors.get(entityClass.getName()).getDescriptor();
      GeneratedValueMetadata generatedValue=m_generatedValues.get(entityClass);
      String generatorName=generatedValue.getGenerator();
      if (generatorName == null) {
        generatorName="String_Node_Str";
      }
      Sequence sequence=null;
      if (!generatorName.equals("String_Node_Str")) {
        sequence=sequences.get(generatorName);
      }
      if (sequence == null) {
        Enum strategy=generatedValue.getStrategy();
        if (strategy == null || strategy.equals(GenerationType.AUTO)) {
          usesAuto=true;
        }
 else         if (strategy.equals(GenerationType.TABLE)) {
          if (generatorName.equals("String_Node_Str")) {
            sequence=defaultTableSequence;
          }
 else {
            sequence=(Sequence)defaultTableSequence.clone();
            sequence.setName(generatorName);
          }
        }
 else         if (strategy.equals(GenerationType.SEQUENCE)) {
          if (generatorName.equals("String_Node_Str")) {
            sequence=defaultObjectNativeSequence;
          }
 else {
            sequence=(Sequence)defaultObjectNativeSequence.clone();
            sequence.setName(generatorName);
          }
        }
 else         if (strategy.equals(GenerationType.IDENTITY)) {
          if (generatorName.equals("String_Node_Str")) {
            sequence=defaultIdentityNativeSequence;
          }
 else {
            sequence=(Sequence)defaultIdentityNativeSequence.clone();
            sequence.setName(generatorName);
          }
        }
      }
      if (sequence != null) {
        descriptor.setSequenceNumberName(sequence.getName());
        login.addSequence(sequence);
      }
 else {
        String seqName;
        if (generatorName.equals("String_Node_Str")) {
          if (defaultAutoSequence != null) {
            seqName=defaultAutoSequence.getName();
          }
 else {
            seqName=MetadataConstants.DEFAULT_AUTO_GENERATOR;
          }
        }
 else {
          seqName=generatorName;
        }
        descriptor.setSequenceNumberName(seqName);
      }
    }
    if (usesAuto) {
      if (defaultAutoSequence != null) {
        login.setDefaultSequence(defaultAutoSequence);
      }
    }
  }
}