{"id":62,"date":"2020-06-06T00:22:09","date_gmt":"2020-06-05T16:22:09","guid":{"rendered":"https:\/\/playerzhou.com\/blog\/?p=62"},"modified":"2020-06-24T13:39:37","modified_gmt":"2020-06-24T05:39:37","slug":"%e4%bd%bf%e7%94%a8spring-data-neo4j%e6%9f%a5%e8%af%a2%e8%b7%af%e5%be%84","status":"publish","type":"post","link":"https:\/\/playerzhou.com\/blog\/?p=62","title":{"rendered":"\u4f7f\u7528Spring Data Neo4J\u67e5\u8be2\u8def\u5f84"},"content":{"rendered":"\n<p>\u4ee5\u4e00\u4e2a\u7b80\u5355\u7684\u8def\u5f84\u67e5\u8be2\u4e3a\u4f8b\uff0c\u5bf9\u4e8e\u4ee5\u4e0b\u67e5\u8be2\u8bed\u53e5\u6765\u8bf4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Query(\"match p=(n)-[*]-[m] return p\")<\/code><\/pre>\n\n\n\n<p>\u82e5\u4f7f\u7528\u81ea\u5df1\u5b9a\u4e49\u7684\u5173\u7cfb\u7c7b\u6765\u83b7\u53d6\u8be5\u67e5\u8be2\u7684\u8fd4\u56de\u503c\uff0c\u5f97\u5230\u7684\u7ed3\u679c\u662f\u67e5\u8be2\u51fa\u7684\u82e5\u5e72\u8def\u5f84\u7684\u6240\u6709\u8fb9\u7684\u5217\u8868\uff0c\u82e5\u60f3\u83b7\u5f97\u8def\u5f84\u5e8f\u5217\uff0c\u8fd8\u9700\u518d\u5bf9\u5f97\u5230\u7684\u6570\u636e\u8fdb\u884c\u5904\u7406\uff0c\u5e76\u4e0d\u65b9\u4fbf\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u5728Stackoverflow\u4e0a\u641c\u7d22\uff0c\u6211\u5f97\u5230\u5982\u4e0b\u89e3\u51b3\u65b9\u6cd5\uff0c\u5c06\u8fd4\u56de\u503c\u5b9a\u4e49\u4e3a<code>Iterable&lt;Map&lt;String,Object&gt;&gt;<\/code>,\u5176\u4e2d\u6bcf\u4e2aMap\u53ea\u6709\u4e00\u4e2aKey\u503c\u201cp\u201d\uff0c\u5bf9\u5e94value\u5373\u4e3a\u8be5\u6761\u8def\u5f84<\/p>\n\n\n\n<p>\u5728Stackoverflow\u7684\u7b54\u6848\u4e2d\uff0c\u83b7\u53d6\u7684\u8def\u5f84\u53d8\u91cf\u4e3aList\uff0c\u4f46\u7ecf\u8fc7\u5b9e\u9645\u6d4b\u8bd5\uff0c\u4e5f\u8bb8\u662fSpring Data Neo4j\u4fee\u6539\u4e86\u5185\u90e8\u5b9e\u73b0\uff0c\u83b7\u53d6\u7684\u8def\u5f84\u53d8\u91cf\u7c7b\u578b\u4e3a\u6570\u7ec4\uff0c\u6570\u7ec4\u4e2d\u6bcf\u4e2a\u5143\u7d20\u5373\u4ee3\u8868\u8def\u5f84\u4e2d\u7684\u67d0\u4e00\u6761\u8fb9\uff0c\u7c7b\u578b\u4e3aNeo4j Driver\u4e2d\u5b9a\u4e49\u7684\u5185\u90e8\u7c7b\uff0c\u4f46\u901a\u8fc7\u67e5\u770b\u6e90\u7801\u53ef\u4ee5\u53d1\u73b0\uff0c\u8be5\u5185\u90e8\u7c7b\u5b9e\u73b0\u63a5\u53e3<code>Path.Segment<\/code>\uff0c\u56e0\u6b64\u53ef\u76f4\u63a5\u4f7f\u7528\u8be5\u63a5\u53e3\u4f5c\u4e3a\u53d8\u91cf\u7c7b\u578b\uff0c\u81f3\u4e8e\u5982\u4f55\u4f7f\u7528\u83b7\u53d6\u5230\u7684\u53d8\u91cf\uff0c\u53ef\u76f4\u63a5\u53c2\u8003\u76f8\u5e94API\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u5373\u4e3a\u4e2a\u4eba\u4f7f\u7528\u8be5\u65b9\u6cd5\u83b7\u53d6\u8def\u5f84\u7684\u4ee3\u7801\u793a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>     Iterable&lt;Map&lt;String,Object>> iterable =entityRepository.getRelation(entity);\n        List&lt;List&lt;Integer>> result = new ArrayList&lt;>();\n        for(Map&lt;String,Object> row:iterable){\n            List&lt;Integer> tmp_path=new ArrayList&lt;>();\n            tmp_path.add(entity.getStart());\n            Path.Segment[] path= (Path.Segment[]) row.get(\"p\");\n            for(Path.Segment segment:path){\n                Map&lt;String, Object> map=segment.end().asMap();\n                tmp_path.add(Integer.valueOf(map.get(\"entityId\").toString()));\n            }\n            result.add(tmp_path);\n        }\n        return result;<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u4e00\u4e2a\u7b80\u5355\u7684\u8def\u5f84\u67e5\u8be2\u4e3a\u4f8b\uff0c\u5bf9\u4e8e\u4ee5\u4e0b\u67e5\u8be2\u8bed\u53e5\u6765\u8bf4 \u82e5\u4f7f\u7528\u81ea\u5df1\u5b9a\u4e49\u7684\u5173\u7cfb\u7c7b\u6765\u83b7\u53d6\u8be5\u67e5\u8be2\u7684\u8fd4\u56de\u503c\uff0c\u5f97\u5230\u7684\u7ed3\u679c\u662f\u67e5\u8be2\u51fa [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/playerzhou.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/62"}],"collection":[{"href":"https:\/\/playerzhou.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/playerzhou.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/playerzhou.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/playerzhou.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=62"}],"version-history":[{"count":4,"href":"https:\/\/playerzhou.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":67,"href":"https:\/\/playerzhou.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions\/67"}],"wp:attachment":[{"href":"https:\/\/playerzhou.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/playerzhou.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/playerzhou.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}