I have below classes
@Inheritance(strategy=InheritanceType.JOINED)
Class A{
private long a_id;
private C C;
}
Class B extends A{
private D d;
}
Class C{
private long c_id;
}
Class D{
private long d_id;
private Set<B> bs;
}
Here class B is extends Class A. Trying to query as below
Criterion criterion = Restrictions.and(Restrictions.eq(
"b.c", c_instance));
Criteria c = session.createCriteria(D.class, "d")
c.createAlias("bs", "b",JoinType.LEFT_OUTER_JOIN,criterion);
c.createAlias("bs.c","c")
Output Query:
select d.d_id from D d left outer join B bs on d.d_id=bs.d_id and bs.c_id=2489 inner join A on bs.a_id=A.a_id inner join C A.c_id=C.c_id
Im getting an error as c_id is unknonwn column in B. Though the table B doesn't have the column c_id its parent table has. How can I write an query to achive left outer join here?
我猜bs是B类的集合,您正在尝试从B类中获取c.createAlias(“ bs.c”,“ c”)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.