我的一个主表和一个从表是一对多关系,但是从表又与其他表有一对多等关系,

我的一个主表和一个从表是一对多关系,但是从表又与其他表有一对多等关系,

我这样通过主表查询从表:
java代码:


Pm pm = (Pm) getHibernateTemplate().load(Pm.class, id);
for (Iterator list = pm.getPmproject().iterator();list.hasNext(); ) {
PmProject ppfw = (PmProject) list.next();
thread.add(ppfw);
}

主表XML:
java代码:

<set name="pmproject" lazy="true" inverse="true" cascade="all" >
<key column=
"project_id"/>
<one-to-many class=
"com.erp.bean.beanxml.PmProject" />
</set>

从表XML:
java代码:

<many-to-one
name="pm"
column=
"project_id"
class=
"com.erp.bean.beanxml.Pm"
not-null=
"true"/>

<many-to-one
name=
"ccommon"
class=
"com.erp.bean.beanxml.Ccommon"
column=
"common_id"
unique=
"true"/>

....................
我通过主表去查询从表数据的时候结果出现了这样的错误:

net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection

sf.hibernate.util.JDBCExceptionReporter]-[WARN] SQL Error: 1116, SQLState: S1000

2005-03-28 14:13:09,328 [net.sf.hibernate.util.JDBCExceptionReporter]-[ERROR] General error, message from server: "Too many tables. MySQL can only use 31 tables in a join"


由于相关联的表很多;错误中提示有30几个表相互关联,但是我根本用不了那些关联呀;

是这句代码有问题,


for (Iterator list = pm.getPmproject().iterator();list.hasNext(); )

我本希望它只查询出Pmproject中的数据,然后进行叠代出来就可以了;没有想到它把与此表有关联的所有表都查询,所以造成了:

[net.sf.hibernate.util.JDBCExceptionReporter]-[ERROR] General error, message from server: "Too many tables. MySQL can only use 31 tables in a join"

这样的错误;

我的目的是:只查询Pmproject中的数据,而不需要查询与此表有关联的表的信息,

请问有什么好的办法没有?????

建议采取面向模型分析方法重新设计。