0
第一件事我的設置是:不必要的附加標籤要求第一
spring-data-neo4j version: 3.0.0.RELEASE
spring-data-neo4j-rest version: 3.0.0.RELEASE
我使用的春天Neo4j的配置與遠程REST DB訪問:
@Configuration
@EnableTransactionManagement
@EnableNeo4jRepositories(basePackages = "my.package.repository")
public class Neo4JConfig extends Neo4jConfiguration {
@Bean
public GraphDatabaseService graphDatabaseService() {
return new SpringRestGraphDatabase("http://localhost:7474/db/data");
}
}
我有我的倉庫設置爲:
public interface ProductRepository extends GraphRepository<GraphProduct>{}
當在該存儲庫執行的findAll()方法:
個Page<GraphProduct> products = productRepository.findAll(
new PageRequest(page, size, sort != null ? new Sort(sort) : null));
日誌顯示(預期)加密查詢來獲取這些對象:
Executing remote cypher query: MATCH (`graphProduct`:`GraphProduct`) RETURN `graphProduct` params {}
問題
令人意想不到的是,雖然在那之後,後續請求是爲每個節點發送被拿取:
Executing remote cypher query: match (n) where id(n)={nodeId} return labels(n) as labels params {nodeId=32}
Executing remote cypher query: match (n) where id(n)={nodeId} return labels(n) as labels params {nodeId=33}
...
你可以想象這嚴重損害perfo (30個對象= 30個額外的REST請求)
我可以做些什麼來幫助避免這些額外的請求嗎? 這個數據至少可以一次返回所有節點的批量查詢嗎?
UPDATE
不幸的接縫,這個問題會停留一段時間。 我與@Gwendal谷歌小組討論鏈接https://groups.google.com/forum/#!topic/neo4j/GZ8XZ-TEc5c%5B1-25-false%5D去了,它看起來像現在沒有解決方法。
只有我能想到的解決方案是從GG討論可以追溯到類名在節點屬性
:
unfortunately labels are not returned from any of the endpoints with the nodes automatically, so they have to be fetched separately.
Sorry for that.
You can return to the Indexed type-representation strategy with using this config:
<bean id="typeRepresentationStrategyFactory" class="org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory">
<constructor-arg index="0" ref="graphDatabase"/>
<constructor-arg index="1" value="Indexed"/>
</bean>
<neo4j:config storeDirectory="graph.db" base-package="com.example.domain,com.example.domain2"/>
<neo4j:repositories base-package="com.example.repositories"/>
請在答案中包含鏈接的相關部分。如果鏈接的內容發生變化,你的回答將變得毫無用處。 – Tyler