【发布时间】:2014-12-27 22:18:09
【问题描述】:
我有一个如下所示的存储库:
public interface UserRepository extends JpaRepository<User, Long>
{
User findByEmailIgnoreCase(String email);
@Query("select u from User u where u.id in (:ids)")
Set<User> getByIdInSet(@Param("ids") Set<Long> ids);
}
当我调用getByIdInSet 时,我收到以下错误:
Caused by: java.lang.IllegalArgumentException: You have attempted to set a value of type class org.eclipse.persistence.indirection.IndirectSet for parameter ids with expected type of class java.lang.Long from query string select u from User u where u.id in (:ids).
at org.eclipse.persistence.internal.jpa.QueryImpl.setParameterInternal(QueryImpl.java:933)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameter(EJBQueryImpl.java:593)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
显然我不知道是什么意思,因为我已经尝试更改各种数据类型,但仍然得到相同的错误。我传递的一组 id 只包含一个 id。请指出正确的方向。
【问题讨论】:
标签: java jpa spring-data spring-data-jpa