菜鸟求教!SSH数据库多表查询的问题
金融大鹅 2011-11-14 02:05:46 两张表MoveBooking和MoveArea有主外键关系,在ssh项目中自动生成了
<many-to-one name="moveArea" class="com.hancheng.shunfeng.orm.MoveArea" fetch="select" insert="true">
<column name="AREA" precision="22" scale="0" not-null="true" />
</many-to-one>
-----------------------------------
<set name="moveBookings" inverse="true">
<key>
<column name="AREA" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="com.hancheng.shunfeng.orm.MoveBooking" />
</set>
----------------------------------------------
MoveBooking生成的DAO里有多个查询方法,我现在用的是
public List findAll() {
log.debug("finding all MoveBooking instances");
try {
String queryString = "from MoveBooking";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
用这个方法加载所有的moveBooking
我的需求是同时把对应的主表MoveArea也一起加载进来
但是MoveArea总是null
求高手指点迷津·······················