普通SQL语句如下
select * from resinfo a
left join
(select * from discount
where bdate<='2009-11-30' and edate>='2009-11-30') b
on a.resid=b.resid现在有Resinfo和Discount两个类 为一对多关联
其中:
Resinfo.hbm.xml文件为:
<hibernate-mapping>
......
<set name="discounts" inverse="true" >
<key>
<column name="resid" not-null="true" />
</key>
<one-to-many class="com.pojo.Discount" />
</set>
......
</hibernate-mapping>Discount.hbm.xml
<hibernate-mapping>
......
<many-to-one name="resinfo" class="com.pojo.Resinfo" fetch="select">
<column name="resid" not-null="true" />
</many-to-one>
.....
</hibernate-mapping>用HibernateTemplate调用HQL语句达到跟上面普通SQL一样效果的话怎么写呢?谢谢
select * from resinfo a
left join
(select * from discount
where bdate<='2009-11-30' and edate>='2009-11-30') b
on a.resid=b.resid现在有Resinfo和Discount两个类 为一对多关联
其中:
Resinfo.hbm.xml文件为:
<hibernate-mapping>
......
<set name="discounts" inverse="true" >
<key>
<column name="resid" not-null="true" />
</key>
<one-to-many class="com.pojo.Discount" />
</set>
......
</hibernate-mapping>Discount.hbm.xml
<hibernate-mapping>
......
<many-to-one name="resinfo" class="com.pojo.Resinfo" fetch="select">
<column name="resid" not-null="true" />
</many-to-one>
.....
</hibernate-mapping>用HibernateTemplate调用HQL语句达到跟上面普通SQL一样效果的话怎么写呢?谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货