0

我正在尝试获取一个不同的 id 返回列表,这将是很长的……但我正在取回这个 DistinctResultList ……如何处理这个问题,以便他们获得他们期望的结果……这就是我正在做...

@NamedQuery(name="getProvidersByResourceIds", query = "SELECT DISTINCT p.resourceId FROM Provider p WHERE p.resourceId `in :resourceIds")`

除此之外,我尝试通过这样做来获取 resourceIds'...

List<Long> provIDs = (List<Long>) emf.createNamedQuery("getProvidersByResourceIds").setParameter("resourceIds", values).getResultList();

但就像我说的,我不断返回 DistinctResultList... 查看调试器,我可以看到返回的值。我怎样才能把它翻译成有用的东西?

javax.ejb.EJBException: See nested exception; nested exception is: java.lang.IllegalArgumentException: Parameter "Parameter<long>('resourceIds')" declared in "SELECT p FROM Provider p WHERE p.resourceId = :resourceIds" is set to value of "org.apache.openjpa.kernel.DistinctResultList@35fb35fb" of type "org.apache.openjpa.kernel.DistinctResultList", but this parameter is bound to a field of type "long".
java.lang.IllegalArgumentException: Parameter "Parameter<long>('resourceIds')" declared in "SELECT p FROM Provider p WHERE p.resourceId = :resourceIds" is set to value of "org.apache.openjpa.kernel.DistinctResultList@35fb35fb" of type "org.apache.openjpa.kernel.DistinctResultList", but this parameter is bound to a field of type "long"
4

1 回答 1

1

将您的查询更改为:

@NamedQuery(name="getProvidersByResourceIds", 
    query = "SELECT DISTINCT p.resourceId FROM Provider p WHERE p.resourceId in (:resourceIds)");
于 2012-06-26T12:35:07.763 回答