Spring JPA存储库& JSR310&原生查询

时间:2015-01-29 15:17:29

标签: java spring spring-data-jpa

看来JSR310 Type Instant在本机查询中绑定为VARBINARY:

@Query(value = "select * from state_entry where timestamp > ?1 and deleted = false limit 10", nativeQuery = true)

日志输出:

2015-01-29 15:41:26.685 TRACE 12250 --- [  XNIO-1 task-1] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [VARBINARY] - [2015-01-26T13:24:07Z]

等效的JPA查询没有问题:

@Query("FROM StateEntry where timestamp > ?1")

日志输出:

2015-01-29 15:50:37.228 TRACE 12791 --- [  XNIO-1 task-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [TIMESTAMP] - [2015-01-26T13:24:07Z]
2015-01-29 15:50:37.228 TRACE 12791 --- [  XNIO-1 task-2] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [TIMESTAMP] - [2015-01-26 14:24:07.0]

是否有解决方法或我是否必须在本机查询中使用java.util.Date?

我使用的是spring-data-jpa 1.8.0 M1顺便说一句。

1 个答案:

答案 0 :(得分:0)

显然它按设计工作(JPA规范)。 https://jira.spring.io/browse/DATAJPA-671