Program: 176119
Project: 176119
Buggy source:
/** 
 * @param tableName
 * @param entity
 * @param rowId
 * @param metaModel
 * @param attributes
 * @param columnWrapper
 * @param persistentData
 * @return
 * @throws IOException
 */
public Map<String,HBaseDataWrapper> preparePersistentData(String tableName,String columnFamily,Object entity,Object rowId,MetamodelImpl metaModel,Set<Attribute> attributes,HBaseDataWrapper columnWrapper,List<HBaseDataWrapper> persistentData) throws IOException {
  Map<String,HBaseDataWrapper> persistentDataWrappers=new HashMap<String,HBaseDataWrapper>();
  persistentDataWrappers.put(columnFamily,columnWrapper);
  for (  Attribute column : attributes) {
    String fieldName=((AbstractAttribute)column).getJPAColumnName();
    String columFamilyTableName=((AbstractAttribute)column).getTableName() != null ? ((AbstractAttribute)column).getTableName() : columnFamily;
    addColumnFamilyToTable(tableName,columFamilyTableName);
    persistentDataWrappers=getHBaseWrapperObj(rowId,entity,columFamilyTableName,persistentDataWrappers,persistentData);
    columnWrapper=persistentDataWrappers.get(columFamilyTableName);
    columnWrapper.setColumnFamily(columFamilyTableName);
    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) {
              String embeddableColumFamilyName=columFamilyTableName;
              Map<Map<String,Class<?>>,HBaseDataWrapper> embeDaableDataWrappers=new HashMap<Map<String,Class<?>>,HBaseDataWrapper>();
              for (              Attribute attribute : columns) {
                embeddableColumFamilyName=((AbstractAttribute)attribute).getTableName() != null ? ((AbstractAttribute)attribute).getTableName() : columFamilyTableName;
                String columnName=columnFamilyName + Constants.EMBEDDED_COLUMN_NAME_DELIMITER + ((AbstractAttribute)attribute).getJPAColumnName()+ Constants.EMBEDDED_COLUMN_NAME_DELIMITER+ count;
                Map<String,Class<?>> embeddableMap=new HashMap<String,Class<?>>();
                embeddableMap.put(embeddableColumFamilyName,obj.getClass());
                embeDaableDataWrappers=getEmbeddableHBaseWrapperObj(rowId,obj,embeddableColumFamilyName,embeDaableDataWrappers,persistentData,embeddableMap);
                HBaseDataWrapper embeddableColumnWrapper=embeDaableDataWrappers.get(embeddableMap);
                embeddableColumnWrapper.setColumnFamily(embeddableColumFamilyName);
                embeddableColumnWrapper.addColumn(columnName,attribute);
                embeddableColumnWrapper.addValue(columnName,PropertyAccessorHelper.getObject(obj,(Field)attribute.getJavaMember()));
              }
              count++;
            }
          }
 else {
            int lastEmbeddedObjectCount=ecCacheHandler.getLastElementCollectionObjectCount(rowId);
            for (            Object obj : (Collection)columnFamilyObject) {
              String embeddableColumFamilyName=columFamilyTableName;
              dynamicCFName=ecCacheHandler.getElementCollectionObjectName(rowId,obj);
              if (dynamicCFName == null) {
                ++lastEmbeddedObjectCount;
                Map<Map<String,Class<?>>,HBaseDataWrapper> embeDaableDataWrappers=new HashMap<Map<String,Class<?>>,HBaseDataWrapper>();
                for (                Attribute attribute : columns) {
                  embeddableColumFamilyName=((AbstractAttribute)attribute).getTableName() != null ? ((AbstractAttribute)attribute).getTableName() : columFamilyTableName;
                  String columnName=columnFamilyName + Constants.EMBEDDED_COLUMN_NAME_DELIMITER + ((AbstractAttribute)attribute).getJPAColumnName()+ Constants.EMBEDDED_COLUMN_NAME_DELIMITER+ (lastEmbeddedObjectCount);
                  Map<String,Class<?>> embeddableMap=new HashMap<String,Class<?>>();
                  embeddableMap.put(embeddableColumFamilyName,obj.getClass());
                  embeDaableDataWrappers=getEmbeddableHBaseWrapperObj(rowId,obj,embeddableColumFamilyName,embeDaableDataWrappers,persistentData,embeddableMap);
                  HBaseDataWrapper embeddableColumnWrapper=embeDaableDataWrappers.get(embeddableMap);
                  embeddableColumnWrapper.setColumnFamily(embeddableColumFamilyName);
                  embeddableColumnWrapper.addColumn(columnName,attribute);
                  embeddableColumnWrapper.addValue(columnName,PropertyAccessorHelper.getObject(obj,(Field)attribute.getJavaMember()));
                }
              }
            }
            ecCacheHandler.clearCache();
          }
        }
 else {
          Map<Map<String,Class<?>>,HBaseDataWrapper> embeDaableDataWrappers=new HashMap<Map<String,Class<?>>,HBaseDataWrapper>();
          String embeddableColumFamilyName=columFamilyTableName;
          for (          Attribute attribute : columns) {
            embeddableColumFamilyName=((AbstractAttribute)attribute).getTableName() != null ? ((AbstractAttribute)attribute).getTableName() : columFamilyTableName;
            Map<String,Class<?>> embeddableMap=new HashMap<String,Class<?>>();
            embeddableMap.put(embeddableColumFamilyName,columnFamilyObject.getClass());
            embeDaableDataWrappers=getEmbeddableHBaseWrapperObj(rowId,columnFamilyObject,embeddableColumFamilyName,embeDaableDataWrappers,persistentData,embeddableMap);
            HBaseDataWrapper embeddableColumnWrapper=embeDaableDataWrappers.get(embeddableMap);
            embeddableColumnWrapper.setColumnFamily(embeddableColumFamilyName);
            embeddableColumnWrapper.addColumn(((AbstractAttribute)attribute).getJPAColumnName(),attribute);
            embeddableColumnWrapper.addValue(((AbstractAttribute)attribute).getJPAColumnName(),PropertyAccessorHelper.getObject(columnFamilyObject,(Field)attribute.getJavaMember()));
          }
        }
      }
    }
 else     if (!column.isAssociation()) {
      columnWrapper.addColumn(((AbstractAttribute)column).getJPAColumnName(),column);
      columnWrapper.addValue(((AbstractAttribute)column).getJPAColumnName(),PropertyAccessorHelper.getObject(entity,(Field)column.getJavaMember()));
    }
  }
  return persistentDataWrappers;
}

Fixed version (ground truth):
/** 
 * @param tableName
 * @param entity
 * @param rowId
 * @param metaModel
 * @param attributes
 * @param columnWrapper
 * @param persistentData
 * @return
 * @throws IOException
 */
public Map<String,HBaseDataWrapper> preparePersistentData(String tableName,String columnFamily,Object entity,Object rowId,MetamodelImpl metaModel,Set<Attribute> attributes,HBaseDataWrapper columnWrapper,List<HBaseDataWrapper> persistentData) throws IOException {
  Map<String,HBaseDataWrapper> persistentDataWrappers=new HashMap<String,HBaseDataWrapper>();
  persistentDataWrappers.put(columnFamily,columnWrapper);
  for (  Attribute column : attributes) {
    String fieldName=((AbstractAttribute)column).getJPAColumnName();
    String columFamilyTableName=((AbstractAttribute)column).getTableName() != null ? ((AbstractAttribute)column).getTableName() : columnFamily;
    persistentDataWrappers=getHBaseWrapperObj(rowId,entity,columFamilyTableName,persistentDataWrappers,persistentData);
    columnWrapper=persistentDataWrappers.get(columFamilyTableName);
    columnWrapper.setColumnFamily(columFamilyTableName);
    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) {
              String embeddableColumFamilyName=columFamilyTableName;
              Map<Map<String,Class<?>>,HBaseDataWrapper> embeDaableDataWrappers=new HashMap<Map<String,Class<?>>,HBaseDataWrapper>();
              for (              Attribute attribute : columns) {
                embeddableColumFamilyName=((AbstractAttribute)attribute).getTableName() != null ? ((AbstractAttribute)attribute).getTableName() : columFamilyTableName;
                String columnName=columnFamilyName + Constants.EMBEDDED_COLUMN_NAME_DELIMITER + ((AbstractAttribute)attribute).getJPAColumnName()+ Constants.EMBEDDED_COLUMN_NAME_DELIMITER+ count;
                Map<String,Class<?>> embeddableMap=new HashMap<String,Class<?>>();
                embeddableMap.put(embeddableColumFamilyName,obj.getClass());
                embeDaableDataWrappers=getEmbeddableHBaseWrapperObj(rowId,obj,embeddableColumFamilyName,embeDaableDataWrappers,persistentData,embeddableMap);
                HBaseDataWrapper embeddableColumnWrapper=embeDaableDataWrappers.get(embeddableMap);
                embeddableColumnWrapper.setColumnFamily(embeddableColumFamilyName);
                embeddableColumnWrapper.addColumn(columnName,attribute);
                embeddableColumnWrapper.addValue(columnName,PropertyAccessorHelper.getObject(obj,(Field)attribute.getJavaMember()));
              }
              count++;
            }
          }
 else {
            int lastEmbeddedObjectCount=ecCacheHandler.getLastElementCollectionObjectCount(rowId);
            for (            Object obj : (Collection)columnFamilyObject) {
              String embeddableColumFamilyName=columFamilyTableName;
              dynamicCFName=ecCacheHandler.getElementCollectionObjectName(rowId,obj);
              if (dynamicCFName == null) {
                ++lastEmbeddedObjectCount;
                Map<Map<String,Class<?>>,HBaseDataWrapper> embeDaableDataWrappers=new HashMap<Map<String,Class<?>>,HBaseDataWrapper>();
                for (                Attribute attribute : columns) {
                  embeddableColumFamilyName=((AbstractAttribute)attribute).getTableName() != null ? ((AbstractAttribute)attribute).getTableName() : columFamilyTableName;
                  String columnName=columnFamilyName + Constants.EMBEDDED_COLUMN_NAME_DELIMITER + ((AbstractAttribute)attribute).getJPAColumnName()+ Constants.EMBEDDED_COLUMN_NAME_DELIMITER+ (lastEmbeddedObjectCount);
                  Map<String,Class<?>> embeddableMap=new HashMap<String,Class<?>>();
                  embeddableMap.put(embeddableColumFamilyName,obj.getClass());
                  embeDaableDataWrappers=getEmbeddableHBaseWrapperObj(rowId,obj,embeddableColumFamilyName,embeDaableDataWrappers,persistentData,embeddableMap);
                  HBaseDataWrapper embeddableColumnWrapper=embeDaableDataWrappers.get(embeddableMap);
                  embeddableColumnWrapper.setColumnFamily(embeddableColumFamilyName);
                  embeddableColumnWrapper.addColumn(columnName,attribute);
                  embeddableColumnWrapper.addValue(columnName,PropertyAccessorHelper.getObject(obj,(Field)attribute.getJavaMember()));
                }
              }
            }
            ecCacheHandler.clearCache();
          }
        }
 else {
          Map<Map<String,Class<?>>,HBaseDataWrapper> embeDaableDataWrappers=new HashMap<Map<String,Class<?>>,HBaseDataWrapper>();
          String embeddableColumFamilyName=columFamilyTableName;
          for (          Attribute attribute : columns) {
            embeddableColumFamilyName=((AbstractAttribute)attribute).getTableName() != null ? ((AbstractAttribute)attribute).getTableName() : columFamilyTableName;
            Map<String,Class<?>> embeddableMap=new HashMap<String,Class<?>>();
            embeddableMap.put(embeddableColumFamilyName,columnFamilyObject.getClass());
            embeDaableDataWrappers=getEmbeddableHBaseWrapperObj(rowId,columnFamilyObject,embeddableColumFamilyName,embeDaableDataWrappers,persistentData,embeddableMap);
            HBaseDataWrapper embeddableColumnWrapper=embeDaableDataWrappers.get(embeddableMap);
            embeddableColumnWrapper.setColumnFamily(embeddableColumFamilyName);
            embeddableColumnWrapper.addColumn(((AbstractAttribute)attribute).getJPAColumnName(),attribute);
            embeddableColumnWrapper.addValue(((AbstractAttribute)attribute).getJPAColumnName(),PropertyAccessorHelper.getObject(columnFamilyObject,(Field)attribute.getJavaMember()));
          }
        }
      }
    }
 else     if (!column.isAssociation()) {
      columnWrapper.addColumn(((AbstractAttribute)column).getJPAColumnName(),column);
      columnWrapper.addValue(((AbstractAttribute)column).getJPAColumnName(),PropertyAccessorHelper.getObject(entity,(Field)column.getJavaMember()));
    }
  }
  return persistentDataWrappers;
}