假設我有一個與存儲在列表中的實體關聯的ID列表。如果我將這個列表傳遞給一個函數,如果我在JPQL中使用IN關鍵字,那麼我應該得到與在使用中的定時查詢語言中相同的功能,我假設...org.apache.openjpa.persistence.ArgumentException在查詢openJPA中進行
但是我遇到這種異常,只要我嘗試我的代碼運行...我的代碼看起來像這樣...
public void UpdateEntityByPerson(int ID, int[] EntityIDs) {
// TODO Auto-generated method stub
List<EntityList> distList = null;//new ArrayList<EntityList>();
try{
Provider prov = emf.find(Provider.class, new Long(ID));
prov.setDistListPermCollection(null);
distList = emf.createNamedQuery("getEntityListByListIds").setParameter("listIds", EntityIDs).getResultList();
prov.setEntityListPermCollection(distList);
}
catch(Exception ex){
System.out.println("Exception : "+ex);
ex.printStackTrace();
}
}
這裏是我的JPQL命名查詢...
@NamedQuery(name="getEntityistByListIds", query = "SELECT d FROM EntityList d WHERE d.listId in :listIds"),
我應該怎麼做是錯在這裏幹什麼?我想到的一件事是我有一個整數數組...... EntityIDs實際上是很長的......可能會導致輕微的brew-ha-ha!