在java.util.Date
属性上查询关系时,我应该使用什么语法?我尝试使用类似的查询(这只是一个示例,以显示我正在尝试做什么,所以请不要注意那里的变量名称):
@Query("start n1=node({0}) match n1-[r:TYPE]->n2 where r.dateCreated>={1} return r")
Page<Relationship> findAll(Node node, long date, Pageable pager);
但它会引发以下错误:
Caused by: Don't know how to compare that. Left: 1339845862883; Right: 1339827156836
at org.neo4j.cypher.internal.Comparer$class.compareValuesOfDifferentTypes(Comparer.scala:45)
at org.neo4j.cypher.internal.Comparer$class.compare(Comparer.scala:67)
at org.neo4j.cypher.commands.ComparablePredicate.compare(ComparablePredicate.scala:30)
at org.neo4j.cypher.commands.ComparablePredicate.isMatch(ComparablePredicate.scala:41)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher$$anonfun$isMatchSoFar$1.apply(PatternMatcher.scala:148)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher$$anonfun$isMatchSoFar$1.apply(PatternMatcher.scala:148)
我也试过传递一个Date,但它只是抛出相同的错误,但试图比较Long和Date。
我使用的是spring-data-neo4j版本2.0.1.RELEASE
答案 0 :(得分:2)
因此,date属性的long值在图形中存储为字符串(在较新版本的SDN中,您可以在日期字段中定义@GraphProperty(targetType = long.class)。
因此,如果将参数值传递为String.valueOf(longValue)