Database: MySQL (InnoDB)
Hibernate version:
3.2.6
JDK 1.5
class A{
//
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinTable( name = "a_b",
joinColumns = {@JoinColumn(name = "a_id")},
inverseJoinColumns = {@JoinColumn(name = "b_id")})
private Set<B> bs = new HashSet<B>();
//
}
class B{
//
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE},
mappedBy = "bs")
private Set<A> as = new HashSet<A>();
//
}
Now in the dao i am writing a query like this:
// bs is an ArrayList
session.createQuery("from A as a where ((:x) in (a.bs))")
.setParameterList("x", bs)
.list();
I am getting
org.hibernate.exception.SQLGrammarException: could not execute query
......
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException:You have an error in your SQL syntax;
.......
The SQL generated was
select
a0_.a_id as a1_1_,
a0_.submit_timestamp as submit2_1_,
from
a a0_,
a_b bs1_,
b b2_
where
a0_.a_id=bs1_.a_id
and bs1_.b_id=b2_.b_id
and (
? in (
.
)
)
Cant we query like this? Collection in Collection?
|