Program: 176365
Project: 176365
Buggy source:
/** 
 * @param tableName
 * @param entity
 * @param rowId
 * @param metaModel
 * @param attributes
 * @param columnWrapper
 * @param persistentData
 * @return
 * @throws IOException
 */
public void preparePersistentData(String tableName,String columnFamily,Object entity,Object rowId,MetamodelImpl metaModel,Set<Attribute> attributes,HBaseDataWrapper columnWrapper,List<HBaseDataWrapper> persistentData) throws IOException {
  for (  Attribute column : attributes) {
    String fieldName=((AbstractAttribute)column).getJPAColumnName();
    Class javaType=((AbstractAttribute)column).getBindableJavaType();
    if (metaModel.isEmbeddable(javaType)) {
      String columnFamilyName=((AbstractAttribute)column).getJPAColumnName();
      Field columnFamilyField=(Field)column.getJavaMember();
      Object columnFamilyObject=null;
      try {
        columnFamilyObject=PropertyAccessorHelper.getObject(entity,columnFamilyField);
      }
 catch (      PropertyAccessException paex) {
        log.error("String_Node_Str",columnFamilyName,entity);
        throw new KunderaException(paex);
      }
      if (columnFamilyObject != null) {
        Set<Attribute> columns=metaModel.embeddable(javaType).getAttributes();
        Map<String,Attribute> columnNameToAttribute=new HashMap<String,Attribute>();
        if (column.isCollection()) {
          String dynamicCFName=null;
          ElementCollectionCacheManager ecCacheHandler=ElementCollectionCacheManager.getInstance();
          if (ecCacheHandler.isCacheEmpty()) {
            int count=0;
            for (            Object obj : (Collection)columnFamilyObject) {
              for (              Attribute attribute : columns) {
                columnNameToAttribute.put(columnFamilyName + Constants.EMBEDDED_COLUMN_NAME_DELIMITER + ((AbstractAttribute)attribute).getJPAColumnName()+ Constants.EMBEDDED_COLUMN_NAME_DELIMITER+ count,attribute);
              }
              persistentData.add(new HBaseDataWrapper(rowId,columnNameToAttribute,obj,columnFamily));
              count++;
            }
          }
 else {
            int lastEmbeddedObjectCount=ecCacheHandler.getLastElementCollectionObjectCount(rowId);
            for (            Object obj : (Collection)columnFamilyObject) {
              dynamicCFName=ecCacheHandler.getElementCollectionObjectName(rowId,obj);
              if (dynamicCFName == null) {
                for (                Attribute attribute : columns) {
                  columnNameToAttribute.put(columnFamilyName + Constants.EMBEDDED_COLUMN_NAME_DELIMITER + ((AbstractAttribute)attribute).getJPAColumnName()+ Constants.EMBEDDED_COLUMN_NAME_DELIMITER+ (++lastEmbeddedObjectCount),attribute);
                }
              }
              persistentData.add(new HBaseDataWrapper(rowId,columnNameToAttribute,obj,columnFamily));
            }
            ecCacheHandler.clearCache();
          }
        }
 else {
          for (          Attribute attribute : columns) {
            columnNameToAttribute.put(((AbstractAttribute)attribute).getJPAColumnName(),attribute);
          }
          if (columnFamilyField.isAnnotationPresent(Embedded.class)) {
            persistentData.add(new HBaseDataWrapper(rowId,columnNameToAttribute,columnFamilyObject,columnFamily));
          }
 else {
            persistentData.add(new HBaseDataWrapper(rowId,columnNameToAttribute,columnFamilyObject,columnFamily));
          }
        }
      }
    }
 else     if (!column.isAssociation()) {
      columnWrapper.addColumn(((AbstractAttribute)column).getJPAColumnName(),column);
    }
  }
}

Fixed version (ground truth):
/** 
 * @param tableName
 * @param entity
 * @param rowId
 * @param metaModel
 * @param attributes
 * @param columnWrapper
 * @param persistentData
 * @return
 * @throws IOException
 */
public void preparePersistentData(String tableName,String columnFamily,Object entity,Object rowId,MetamodelImpl metaModel,Set<Attribute> attributes,HBaseDataWrapper columnWrapper,List<HBaseDataWrapper> persistentData) throws IOException {
  for (  Attribute column : attributes) {
    String fieldName=((AbstractAttribute)column).getJPAColumnName();
    Class javaType=((AbstractAttribute)column).getBindableJavaType();
    if (metaModel.isEmbeddable(javaType)) {
      String columnFamilyName=((AbstractAttribute)column).getJPAColumnName();
      Field columnFamilyField=(Field)column.getJavaMember();
      Object columnFamilyObject=null;
      try {
        columnFamilyObject=PropertyAccessorHelper.getObject(entity,columnFamilyField);
      }
 catch (      PropertyAccessException paex) {
        log.error("String_Node_Str",columnFamilyName,entity);
        throw new KunderaException(paex);
      }
      if (columnFamilyObject != null) {
        Set<Attribute> columns=metaModel.embeddable(javaType).getAttributes();
        Map<String,Attribute> columnNameToAttribute=new HashMap<String,Attribute>();
        Map<String,Object> columnNameToValue=new HashMap<String,Object>();
        if (column.isCollection()) {
          String dynamicCFName=null;
          ElementCollectionCacheManager ecCacheHandler=ElementCollectionCacheManager.getInstance();
          if (ecCacheHandler.isCacheEmpty()) {
            int count=0;
            for (            Object obj : (Collection)columnFamilyObject) {
              for (              Attribute attribute : columns) {
                String columnName=columnFamilyName + Constants.EMBEDDED_COLUMN_NAME_DELIMITER + ((AbstractAttribute)attribute).getJPAColumnName()+ Constants.EMBEDDED_COLUMN_NAME_DELIMITER+ count;
                columnNameToAttribute.put(columnName,attribute);
                columnNameToValue.put(columnName,PropertyAccessorHelper.getObject(obj,(Field)attribute.getJavaMember()));
              }
              persistentData.add(new HBaseDataWrapper(rowId,columnNameToAttribute,columnNameToValue,obj,columnFamily));
              count++;
            }
          }
 else {
            int lastEmbeddedObjectCount=ecCacheHandler.getLastElementCollectionObjectCount(rowId);
            for (            Object obj : (Collection)columnFamilyObject) {
              dynamicCFName=ecCacheHandler.getElementCollectionObjectName(rowId,obj);
              if (dynamicCFName == null) {
                ++lastEmbeddedObjectCount;
                for (                Attribute attribute : columns) {
                  String columnName=columnFamilyName + Constants.EMBEDDED_COLUMN_NAME_DELIMITER + ((AbstractAttribute)attribute).getJPAColumnName()+ Constants.EMBEDDED_COLUMN_NAME_DELIMITER+ (lastEmbeddedObjectCount);
                  columnNameToAttribute.put(columnName,attribute);
                  columnNameToValue.put(columnName,PropertyAccessorHelper.getObject(obj,(Field)attribute.getJavaMember()));
                }
              }
              persistentData.add(new HBaseDataWrapper(rowId,columnNameToAttribute,columnNameToValue,obj,columnFamily));
            }
            ecCacheHandler.clearCache();
          }
        }
 else {
          for (          Attribute attribute : columns) {
            columnNameToAttribute.put(((AbstractAttribute)attribute).getJPAColumnName(),attribute);
            columnNameToValue.put(((AbstractAttribute)attribute).getJPAColumnName(),PropertyAccessorHelper.getObject(columnFamilyObject,(Field)attribute.getJavaMember()));
          }
          if (columnFamilyField.isAnnotationPresent(Embedded.class)) {
            persistentData.add(new HBaseDataWrapper(rowId,columnNameToAttribute,columnNameToValue,columnFamilyObject,columnFamily));
          }
 else {
            persistentData.add(new HBaseDataWrapper(rowId,columnNameToAttribute,columnNameToValue,columnFamilyObject,columnFamily));
          }
        }
      }
    }
 else     if (!column.isAssociation()) {
      columnWrapper.addColumn(((AbstractAttribute)column).getJPAColumnName(),column);
      columnWrapper.addValue(((AbstractAttribute)column).getJPAColumnName(),PropertyAccessorHelper.getObject(entity,(Field)column.getJavaMember()));
    }
  }
}