我有以下课程
@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;
}
这里B类扩展了A类。试图查询如下
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")
输出查询:
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
我得到一个错误,因为c中的c_id是unknonwn列。虽然表B没有其父表所具有的列c_id。如何在此处编写查询以实现左外连接?
答案 0 :(得分:0)
我猜bs是一组B级,你试图从B级获取c.createAlias(&#34; bs.c&#34;,&#34; c&#34;),这是不存在的