0
我在構建數據庫時遇到了一些問題。我有這個兩個HBM映射:Sakai Hibernate延遲初始化
<class name="br.unicamp.iel.model.Module" table="readinweb_modules">
<id name="id" type="java.lang.Long">
<generator class="increment" />
</id>
<many-to-one name="course" class="br.unicamp.iel.model.Course"
column="course_id" fetch="select" />
<property name="position" type="integer" />
<property name="module_grammar" type="text" />
</class>
<class name="br.unicamp.iel.model.Course" table="readinweb_courses">
<id name="id" type="java.lang.Long">
<generator class="increment" />
</id>
<property name="title" length="255" not-null="true" type="string" />
<property name="idiom" length="255" not-null="true" type="string" />
<property name="description" type="text" />
<set name="courseModules" table="readinweb_modules"
inverse="true" lazy="true" fetch="select">
<key column="id" not-null="true" />
<one-to-many class="br.unicamp.iel.model.Module" />
</set>
</class>
,當我嘗試訪問我的邏輯bean作爲數據: 列表模塊=新的ArrayList(dao.findById(Course.class, 課程).getCourseModules()) ;
它給了我一個 org.hibernate.LazyInitializationException:無法初始化懶洋洋作用 的集合:br.unicamp.iel.model.Course.courseModules,沒有 會話或會話關閉
你應該真的要求在評論中澄清問題,然後回答何時有解決方案。 – 2014-09-03 02:01:05
嗯,我問了一下代碼,並給了他一個有關懶惰加載工作方式的提示...... – 2014-09-03 02:12:03