Possible Duplicate:
How to write JPA query where parameter is a set?
I have 2 entities
@Entity
public class Container {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Long id;
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
Set<Child> data = newHashSet();
}
@Entity
public class Child {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Long id;
}
Now I want select all containers that contains specified child.
I wrote jpa query select c from Container c where :child in c.data that produce sql
select
container0_.id as id4_
from
Container container0_
cross join Container_Child data1_, Child child2_
where
container0_.id=data1_.Container_id
and data1_.data_id=child2_.id
and (? in (.))
limit ? [42001-168]
and fails with JdbcSQLException. How can I fix it?
Try:
SELECT con FROM Container con JOIN con.data ch WHERE ch = :child