【发布时间】:2014-08-27 19:55:23
【问题描述】:
我在构建数据库时遇到了一些问题。我有这两个 hbm 映射:
<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 上的数据时: 列出模块 = new ArrayList(dao.findById(Course.class, 当然).getCourseModules());
它给了我一个 org.hibernate.LazyInitializationException:延迟初始化失败 角色集合:br.unicamp.iel.model.Course.courseModules,无 会话或会话已关闭
【问题讨论】:
标签: sakai