我拥有以下实体:
@NodeEntity
public class Action {
...
@Index(unique = false)
private Date createDate;
...
}
Action
这是在前一段时间创建的。
为此,我实现了以下存储库方法:
@Repository
public interface ActionRepository {
@Query("MATCH (a:Action)-[:CREATED_BY]->(u:User) WHERE a.entityType = {entityType} AND a.createDate <= {minCreateDate} AND u.id = {userId} RETURN a ORDER BY a.createDate DESC LIMIT 1")
Action findLastByEntityTypeForUser(@Param("entityType") String entityType, @Param("minCreateDate") Date minCreateDate, @Param("userId") Long userId);
}
我使用以下代码来测试此方法:
decisionDao.create("Decision2", "Decision2 description", null, false, null, user1);
Date minStartDate = DateUtils.addMilliseconds(new Date(), -1000 * 60);
Action user1LastAction = actionRepository.findLastByEntityTypeForUser(Decision.class.getSimpleName(), minStartDate, user1.getId());
assertNotNull(user1LastAction); // test fails here because of NPE
但是没有这部分的密码查询
AND a.createDate <= {minCreateDate}
行动
例子
在Neo4j级别,我的数据如下所示:
{
"updateDate":"2017-10-08T12:21:39.15
3Z",
"entityName":"General",
"en
tityType":"CriterionGroup",
"entityId":1,
"id":1,
"type":"CREATE",
"createDate":"2017-10-08T12:21:39.153Z"
}
我做错了什么?如何正确地将日期与SDN/OGM和Cypher进行比较?
还有,有没有办法告诉SDN/OGM存储
java.util.Date
对象为
long
毫秒和as
String
?