Program: 176179
Project: 176179
Buggy source:
/** 
 * Retrieves entity instance of given class,row key and specific fields.
 * @param clazz entity class
 * @param key row key
 * @param connection connection instance.
 * @param fields fields.
 * @return entity instance.
 * @throws InstantiationException throws in case of runtime exception
 * @throws IllegalAccessException throws in case of runtime exception
 */
private Object fetch(Class clazz,Object key,Object connection,byte[][] fields) throws InstantiationException, IllegalAccessException {
  Object result=null;
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(clazz);
  MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(entityMetadata.getPersistenceUnit());
  String rowKey=null;
  if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType())) {
    rowKey=KunderaCoreUtils.prepareCompositeKey(entityMetadata,metaModel,key);
  }
 else {
    ObjectAccessor accessor=new ObjectAccessor();
    rowKey=accessor.toString(key);
  }
  String hashKey=getHashKey(entityMetadata.getTableName(),rowKey);
  try {
    Map<byte[],byte[]> columns=new HashMap<byte[],byte[]>();
    if (fields != null) {
      List<byte[]> fieldValues=null;
      if (resource != null && resource.isActive()) {
        Response response=((Transaction)connection).hmget(getEncodedBytes(hashKey),fields);
        ((Transaction)connection).exec();
        fieldValues=(List<byte[]>)response.get();
      }
 else {
        fieldValues=((Jedis)connection).hmget(getEncodedBytes(hashKey),fields);
      }
      if (fieldValues != null && !fieldValues.isEmpty()) {
        for (int i=0; i < fields.length; i++) {
          columns.put(fields[i],fieldValues.get(i));
        }
      }
    }
 else {
      columns=getColumns(connection,hashKey,columns);
    }
    result=unwrap(entityMetadata,columns,key);
  }
 catch (  JedisConnectionException jedex) {
    return null;
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Retrieves entity instance of given class,row key and specific fields.
 * @param clazz entity class
 * @param key row key
 * @param connection connection instance.
 * @param fields fields.
 * @return entity instance.
 * @throws InstantiationException throws in case of runtime exception
 * @throws IllegalAccessException throws in case of runtime exception
 */
private Object fetch(Class clazz,Object key,Object connection,byte[][] fields) throws InstantiationException, IllegalAccessException {
  Object result=null;
  EntityMetadata entityMetadata=KunderaMetadataManager.getEntityMetadata(clazz);
  MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(entityMetadata.getPersistenceUnit());
  String rowKey=null;
  if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType())) {
    rowKey=KunderaCoreUtils.prepareCompositeKey(entityMetadata,metaModel,key);
  }
 else {
    ObjectAccessor accessor=new ObjectAccessor();
    rowKey=accessor.toString(key);
  }
  String hashKey=getHashKey(entityMetadata.getTableName(),rowKey);
  try {
    Map<byte[],byte[]> columns=new HashMap<byte[],byte[]>();
    if (fields != null) {
      List<byte[]> fieldValues=null;
      if (resource != null && resource.isActive()) {
        Response response=((Transaction)connection).hmget(getEncodedBytes(hashKey),fields);
        ((Transaction)connection).exec();
        fieldValues=(List<byte[]>)response.get();
      }
 else {
        fieldValues=((Jedis)connection).hmget(getEncodedBytes(hashKey),fields);
      }
      if (fieldValues != null && !fieldValues.isEmpty()) {
        for (int i=0; i < fields.length; i++) {
          if (fieldValues.get(i) != null) {
            columns.put(fields[i],fieldValues.get(i));
          }
        }
      }
    }
 else {
      columns=getColumns(connection,hashKey,columns);
    }
    result=unwrap(entityMetadata,columns,key);
  }
 catch (  JedisConnectionException jedex) {
    return null;
  }
  return result;
}