使用openJPA時我可以給List作爲IN參數嗎?我使用的數據庫是MySQL最新版本。我正在嘗試工作的示例查詢如下所示,並且粘貼了我正在獲取的錯誤。請讓我知道我需要做些什麼來完成這項工作。openJPA IN參數類型作爲集合
Select * from table t where c in (?)
.createNativeQuery(TOPIC)
.setParameter(1, listNo)
Where listNo is List<Long>
錯誤
19:46:47,376 ERROR [org.jboss.ejb3.invocation] (http--127.0.0.1-8080-6) JBAS014134: EJB Invocation failed on component TopicService for method public abstract com.zreflect.emyed.vo.circle.TopicVO[] com.zreflect.emyed.ejb.interfaces.ITopicService.getSelectedTopics(long,java.util.List,com.zreflect.emyed.vo.UserSession): javax.ejb.EJBException: <openjpa-2.2.0-r422266:1244990 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: The specified parameter of type "class java.util.ArrayList" is not a valid query parameter.
爲什麼「原生」查詢? JPQL允許IN查詢獲取List – DataNucleus