[Building Sakai] Hibernate lazy initialize

Virgílio Santos virgilio.santos at gmail.com
Wed Jul 16 07:56:13 PDT 2014


Hi

I'm having some issues building my database. I have this two hbm mappings:

<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>


and when I try to access data on my logic bean as:
List<Module> modules = new ArrayList<Module>(dao.findById(Course.class,
                course).getCourseModules());

it gives me a
org.hibernate.LazyInitializationException: failed to lazily initialize
a collection of role: br.unicamp.iel.model.Course.courseModules, no
session or session was closed

Can someone help me?

Thanks

Virgílio
-- 
Deserve's Got Nothing To Do With It


More information about the sakai-dev mailing list