[Building Sakai] Hibernate lazy initialize
Virgílio Santos
virgilio.santos at gmail.com
Sun Jul 20 10:09:23 PDT 2014
Anyone? How to keep the session alive so I can retrieve my data?
On Wed, Jul 16, 2014 at 11:56 AM, Virgílio Santos
<virgilio.santos at gmail.com> wrote:
> 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
--
Deserve's Got Nothing To Do With It
More information about the sakai-dev
mailing list