hql是这样的:
String vrsql = "From VehicleRelevance as vr left join fetch vr.partRelevance as pr where vr.vehicle_id=1 and pr.part_id=2";
但是
pr.part_id是作为partRevelance标的外键 所以必须这样配置:
<property name="part_id" column="PART_ID" type="int" insert="false" update="false"></property>//<span style="color:#ff0000;">这个字段作为外键多对一可以省略 但是作为关联查询必须加上</span>
<many-to-one name="partInfo" column="PART_ID" class="com.tmsm.bean.PartInfo" cascade="none" fetch="join" not-found="ignore"/>