发展环境.
OS: windows 8
IDE : Eclipse Luna with JAVA 8
Postgresql : 9.3.4 in OPENBSD 5.5
Run Code Online (Sandbox Code Playgroud)
其他所有JPA查询,如findFirst3ByTextOrderByTextAsc正常工作.但不是在NativeQuery中,特别是在INTERVAL中
知识库
@RepositoryRestResource(collectionResourceRel = "Nodes", path = "Nodes")
public interface NodeRepository extends
JpaRepository<Node, Integer>,
CrudRepository<Node, Integer>,
PagingAndSortingRepository<Node, Integer>,
Repository<Node, Integer>
{
//1st INTERVAL is native keyword in POSTGRESQL
@Query(value = "SELECT n.* from nodes n WHERE n.node_id = 10510 AND n.last_good_ping > CURRENT_DATE - INTERVAL '1 day' ", nativeQuery = true)
List<Node> getLast24HoursByNodeId();
//2nd
@Query(value = "SELECT n.* from nodes n WHERE n.node_id …Run Code Online (Sandbox Code Playgroud) 我创建了一个带间隔的本地查询。当我day在查询中进行硬编码时,查询工作正常:
@Query(value="select * from orders where created_date < clock_timestamp() - interval ' 5 days'",nativeQuery=true)
Run Code Online (Sandbox Code Playgroud)
但是当我提供这样的数据时@Param:
@Query(value="select * from orders where created_date < clock_timestamp() - interval :day 'days'",nativeQuery=true)
List<Order> getData(@Param("day") String day)
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
由以下原因引起:org.postgresql.util.PSQLException:错误:“ $ 1”或附近的语法错误