2009-06-25 43 views
4

我試圖做一些事情,顯然不JPQL工作:JPQL測試,如果值是一個數組

JPQL:

select c from Car c 
     left join fetch c.owner 
     where c.type in (?1) 
     order by c.model 

代碼:

public List<Car> findCarsFilterByTypes(CarType[] types) { 
    return (List<Car>) this.entityManager.createNamedQuery("dealership.findCarsFilterByTypes") 
      .setParameter(1, types).getResultList(); 
} 

我希望使用數組的簡單途徑可行......但它顯然不......我得到一個無用的例外。

任何人都知道我怎麼會需要去獲得所有處於汽車類型的一些列表中的汽車?

回答

5

好吧我發現如果我使用List而不是CarType [],上面的代碼工作得很好。 :)

相關問題