Program: 176810
Project: 176810
Buggy source:
/** 
 * Returns bytes value for given value.
 * @param jpaFieldName field name.
 * @param m entity metadata
 * @param value value.
 * @return bytes value.
 */
private Bytes getBytesValue(String jpaFieldName,EntityMetadata m,Object value){
  Attribute idCol=m.getIdAttribute();
  MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
  EntityType entity=metaModel.entity(m.getEntityClazz());
  Field f=null;
  boolean isId=false;
  if (((AbstractAttribute)idCol).getJPAColumnName().equals(jpaFieldName)) {
    f=(Field)idCol.getJavaMember();
    isId=true;
  }
 else {
    if (jpaFieldName != null && jpaFieldName.indexOf(Constants.INDEX_TABLE_ROW_KEY_DELIMITER) > 0) {
      String embeddedFieldName=jpaFieldName.substring(0,jpaFieldName.indexOf(Constants.INDEX_TABLE_ROW_KEY_DELIMITER));
      String columnFieldName=jpaFieldName.substring(jpaFieldName.indexOf(Constants.INDEX_TABLE_ROW_KEY_DELIMITER) + 1,jpaFieldName.length());
      Attribute embeddedAttr=entity.getAttribute(embeddedFieldName);
      try {
        Class<?> embeddedClass=embeddedAttr.getJavaType();
        if (Collection.class.isAssignableFrom(embeddedClass)) {
          Class<?> genericClass=PropertyAccessorHelper.getGenericClass((Field)embeddedAttr.getJavaMember());
          f=genericClass.getDeclaredField(columnFieldName);
        }
 else {
          f=embeddedClass.getDeclaredField(columnFieldName);
        }
      }
 catch (      SecurityException e) {
        e.printStackTrace();
      }
catch (      NoSuchFieldException e) {
        e.printStackTrace();
      }
    }
 else {
      String fieldName=m.getFieldName(jpaFieldName);
      Attribute col=entity.getAttribute(fieldName);
      if (col == null) {
        throw new QueryHandlerException("String_Node_Str" + jpaFieldName);
      }
      f=(Field)col.getJavaMember();
    }
  }
  if (f != null && f.getType() != null) {
    return CassandraUtilities.toBytes(value,f);
  }
 else {
    log.error("String_Node_Str" + jpaFieldName);
    throw new QueryHandlerException("String_Node_Str" + jpaFieldName);
  }
}

Fixed version (ground truth):
/** 
 * Returns bytes value for given value.
 * @param jpaFieldName field name.
 * @param m entity metadata
 * @param value value.
 * @return bytes value.
 */
private Bytes getBytesValue(String jpaFieldName,EntityMetadata m,Object value){
  Attribute idCol=m.getIdAttribute();
  MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
  EntityType entity=metaModel.entity(m.getEntityClazz());
  Field f=null;
  boolean isId=false;
  if (((AbstractAttribute)idCol).getJPAColumnName().equals(jpaFieldName)) {
    f=(Field)idCol.getJavaMember();
    isId=true;
  }
 else {
    if (jpaFieldName != null && jpaFieldName.indexOf(Constants.INDEX_TABLE_ROW_KEY_DELIMITER) > 0) {
      String embeddedFieldName=jpaFieldName.substring(0,jpaFieldName.indexOf(Constants.INDEX_TABLE_ROW_KEY_DELIMITER));
      String columnFieldName=jpaFieldName.substring(jpaFieldName.indexOf(Constants.INDEX_TABLE_ROW_KEY_DELIMITER) + 1,jpaFieldName.length());
      Attribute embeddedAttr=entity.getAttribute(embeddedFieldName);
      try {
        Class<?> embeddedClass=embeddedAttr.getJavaType();
        if (Collection.class.isAssignableFrom(embeddedClass)) {
          Class<?> genericClass=PropertyAccessorHelper.getGenericClass((Field)embeddedAttr.getJavaMember());
          f=genericClass.getDeclaredField(columnFieldName);
        }
 else {
          f=embeddedClass.getDeclaredField(columnFieldName);
        }
      }
 catch (      SecurityException e) {
        log.error(e.getMessage());
      }
catch (      NoSuchFieldException e) {
        log.error(e.getMessage());
      }
    }
 else {
      String fieldName=m.getFieldName(jpaFieldName);
      Attribute col=entity.getAttribute(fieldName);
      if (col == null) {
        throw new QueryHandlerException("String_Node_Str" + jpaFieldName);
      }
      f=(Field)col.getJavaMember();
    }
  }
  if (f != null && f.getType() != null) {
    return CassandraUtilities.toBytes(value,f);
  }
 else {
    log.error("String_Node_Str" + jpaFieldName);
    throw new QueryHandlerException("String_Node_Str" + jpaFieldName);
  }
}