比较java.util.Date我有以下实体:SDN5/OGM3在Cypher支架查询
@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
但没有Cypher支架查询AND a.createDate <= {minCreateDate}
的这部分我可以成功找到Action
实例。
在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
毫秒和String
?
谢谢您的回答。有什么办法可以告诉SDN/OGM将'java.util.Date'对象保存为'long'毫秒? – alexanoid
不是我的知识 –
是的你可以: '@Index(unique = false) @DateLong public Date createDate;'''' – nmervaillie