查询以后返回结果,如果是一个list,是怎么解析它的?
发布于 1 个月前 作者 nieyuan1980 117 次浏览 来自 问答

String sqlText = “MATCH(N:WechatDepartment)-[:child]->(M:WechatDepartment) \n” + “WHERE N.departmentId = {departmentId} \n” + //“WHERE N.departmentId = 117 \n” + “RETURN ID(M) as id, M.departmentId as departmentId, M.name as name, M.order as order, M.enable as enable”; Result result = session.run(sqlText, paramentMap);

        //方法1
        List<Record> records = result.list();
        System.out.println("records:" + records.size());
        for (Record record : records) {
            System.out.println("recordsStr:" + records.toString());
            Map<String, Object> recordMap = record.asMap();
            System.out.println("recordMap:" + recordMap);

            //String name = record.get("name").asString();
            //System.out.println("name:" + name);
        }

目前我只找到了循环这种方法,请问还有别的方法吗?

回到顶部