【发布时间】:2016-01-07 14:27:22
【问题描述】:
因此,对于一些复杂的操作,我在我的图形存储库中的自定义查找器方法上使用 @Query 注释使用自定义 Cypher 查询。但是,在检索节点时,它不会检索其直接关系(即只有 1 级)。
@Query("match (node:T) return node Order by node.requestedAt Desc LIMIT 100")
List<T> last100T();
@Query("match (node:T) where node.status = \"REQUESTED\" and timestamp() - node.requestedAt >= 60000 return node")
List<Transit> findUnmatchedAndExpiredT();
我是这样使用它们的 - (代码在 groovy 中):
def nodes = TRepository.findUnmatchedAndExpiredT()
nodes.forEach({
node ->
node.status = TStatus.DECLINED
node.neighbourA.status = NeighbourAStatus.BARRED
def neighbourBQueue = client.queue(node.neighbourB.username)
neighbourBQueue.push(mapper.writeValueAsString(node))
TRepository.save(node)
})
它们是这样相关的:
@NodeEntity
class T{
public T(){
}
@GraphId
Long id
@Relationship(type = "REQUESTED_BY", direction = Relationship.OUTGOING)
NeighbourB neighbourB
@Relationship(type = "SERVICED_BY", direction = Relationship.OUTGOING)
NeighbourA neighbourA
}
当关系确实存在时,邻居 A 和 B 都为空。做什么?我正在使用 Spring boot 1.2.7.RELEASE 和 spring-data-neo4j:4.0.0.RELEASE
【问题讨论】:
标签: java spring groovy spring-data-neo4j-4 neo4j-ogm