因为一些复杂的操作,我正在使用自定义Cypher查询,并在我的图形存储库中的自定义查找器方法上使用@Query注释。然而,虽然它检索了节点,但它没有检索到其直接关系(即仅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都为null。怎么办?我正在使用Spring boot 1.2.7.RELEASE和spring-data-neo4j:4.0.0.RELEASE。