JPQL test if the value is in an array

I tried to do something that does not seem to work in JPQL:

JPQL:

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

code:

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

I was hoping that a simple way to use an array would work ... but it apparently doesn't ... I get a useless exception.

Does anyone know how I will need to get all the cars that are on some lists of car types?

+4
source share
1 answer

Ok, I found that if I use List instead of CarType [], the code above works fine. :)

+5
source

Source: https://habr.com/ru/post/1286783/


All Articles