-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: LazyInitializationException with recursive many-to-many rel.
PostPosted: Fri Aug 25, 2006 6:56 am 
Newbie

Joined: Thu Aug 24, 2006 6:49 am
Posts: 2
I have a big problem. I have a recursive many to many asociation and i get a LazyInitializationException when i access to the lazy collection. My class is Perfil(in spanish) and this is its xbm.xml file:


Code:
<hibernate-mapping package="es.elsendero.comismar.to.acceso">
   <class name="PerfilTO" table="perfil">
      <id name="id" type="int">
         <column name="id" length="4" not-null="true" unique="true" sql-type="int4" />
             <generator class="sequence" >
                <param name="sequence">S_PERFIL</param>
             </generator>
      </id>   
      <version name="version" type="int">
         <column name="version" length="4" sql-type="int4"/>
      </version>
      <property name="nombre" type="java.lang.String">
         <column name="nombre" length="50" sql-type="varchar"/>

...

      </property>
      
      <set name="childs" table="perfileschildsparents"  lazy="true">
         <key>
            <column name="idParent" length="4" sql-type="int4" />                  
         </key>
         <many-to-many class="PerfilTO" column="idChild"/>
      </set>
      
      <set name="parents" table="perfileschildsparents"  inverse="true" lazy="true">
         <key>
            <column name="idChild" length="4" sql-type="int4" />                  
         </key>
         <many-to-many class="PerfilTO" column="idParent"/>
      </set>   
   </class>
</hibernate-mapping>


Hibernate generates two tables in the database. The table perfil and the table perfileschildsparents to manage de many to many relation. It looks ok, but something fails.
When I travel across the tree, Hibernate throws a LazyInitializationException when I access to a Perfil that hasnĀ“t got childs, but not always. Sometimes, I access to a Perfil without childs and its ok. The application works randomly. This it's insane!!!. I use the OpenSessionInView pattern with a Filter. I have copied de filter and the HibernateUtil class from the caveat emptor example application to test and I this they are ok.

Somebody has implemented this type of relation???????
Is the file correct????

I need your help.


Thanks!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.