JPA passing list to IN clause in named native query

前端 未结 10 1080

I know I can pass a list to named query in JPA, but how about NamedNativeQuery? I have tried many ways but still can\'t just pass the list to a NamedNativeQuery. Anyone know

10条回答
  •  臣服心动
    2020-11-30 07:48

    A list is not a valid parameter for a native SQL query, as it cannot be bound in JDBC. You need to have a parameter for each argument in the list.

    where u.user_id in (?id1, ?id2)

    This is supported through JPQL, but not SQL, so you could use JPQL instead of a native query.

    Some JPA providers may support this, so you may want to log a bug with your provider.

提交回复
热议问题