Query query = session.createQuery("from Office o where o.customer.customerId = ? order by officeId asc"); 你上面的是个什么意思? o.customer.customerId这个地方???/,,不懂。。
用lazy可能会有很多源码要改,暂缓。有个很奇怪的现象,不知道大家能不能有点启发,我加第一个office,load list of offices时得不到这个office的资料,但当我再加第二个office时并load list of offices时,我得到了第一个office的资料,依次类推,当加了10个office资料后,我得到含前9个office的list..怎么办???
你上面的是个什么意思?
o.customer.customerId这个地方???/,,不懂。。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.macroview.nco.dao">
<class name="Office" table="office">
<id name="officeId" column="office_id">
</id>
<property name="officeName" column="office_name"/>
<property name="officeCity" column="office_city"/>
<property name="officeType" column="office_type"/>
<property name="scoreMaplet" column="score_maplet"/>
<property name="officeAddress" column="office_address"/>
<property name="officePhone" column="office_phone"/>
<property name="officeFax" column="office_fax"/>
<property name="businessPerson" column="business_person"/>
<property name="businessPhone" column="business_phone"/>
<property name="businessEmail" column="business_email"/>
<property name="techPerson" column="tech_person"/>
<property name="techPhone" column="tech_phone"/>
<property name="techEmail" column="tech_email"/>
<many-to-one name="customer" column="office_customer_id" not-null="true" lazy="false" update="false"/>
<set name="device" inverse="true" lazy="false" order-by="device_id" cascade="all">
<key column="device_office_id"/>
<one-to-many class="Device"/>
</set>
</class></hibernate-mapping>
正常的话有可能是数据太多,或office关联太深,加上延迟加载试试,lazy=true