本机查询IN子句抛出sql错误

时间:2017-01-10 08:22:57

标签: java jpa jpa-2.0

以下查询给出了#include "uart.h" /** * \brief The global object for accessing UART. */ Uart uart(FIFO_SIZE_UART, &timer_a); /** * \brief The global timer object. */ Timer_A timer_a; 之类的错误 我在Missing IN or OUT parameter at index:: 1参数IN中尝试了无括号。但仍然是同样的错误。

... WHERE p.SALES_TYPE IN :types

stacktrace:

public List getWithinXDays(ArrayList<String> salesTypes,String sId, String  xdays) {

    Query q  = em.createNativeQuery("SELECT p.ORDER_ID FROM formtable p WHERE p.SALES_TYPE IN (:types) AND p.MCODE=:sid AND TRUNC(SYSDATE - p.creationdate) <=:days");
    q.setParameter("types",salesTypes);
    q.setParameter("sid",sId);
    q.setParameter("days",xdays);
    List salesOrderRow = q.getResultList();
    return salesOrderRow;
}

1 个答案:

答案 0 :(得分:1)

JPA不支持本地查询的array参数。要么重写代码以使用JPQL,要么为IN子句设置每个条目,如下面的答案所述:JPA passing list to IN clause in named native query