hibernate的left join外连接问题。
Hsql语句:
select wp from TbWhPlanbill wp left join wp.tbCustSet as c
TbWhplanbill.hdm.xml:
...
<id name="planbillId" column="planbill_id" type="java.lang.Long">
<generator class="increment"/>
</id>
<property name="custId" column="cust_id" type="java.lang.Long" />
<set name="tbCustSet" inverse="true">
<key column="cust_id">
<one-to-many class="com.TbCust"/>
</set>
...
Hsql语句:
select wp from TbWhPlanbill wp left join wp.tbCustSet as c
翻译为标准的sql为:
select
tbwhplanbi0_.planbill_id as planbill1_954_,
tbwhplanbi0_.cust_id as order2_954_
from
tb_wh_planbill tbwhplanbi0_
left outer join
TB_CUST tbcustset1_
on tbwhplanbi0_.planbill_id=tbcustset1_.cust_id
问题在这里,默认是用TbWhPlanbill的主键来left join tb_cust的主键:
on tbwhplanbi0_.planbill_id=tbcustset1_.cust_id
实际上我是想
on tbwhplanbi0_.cust_id=tbcustset1_.cust_id
也就是用TbWhPlanbill的其中一个列cust_id来对应TbCust的主键cust_id。
可以这样实现吗?怎么配置?怎么弄。
请大家帮忙,谢谢