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: Lazy initialization problem while using composite-elements
PostPosted: Tue Apr 10, 2007 8:08 am 
Newbie

Joined: Thu Apr 05, 2007 12:12 pm
Posts: 2
I've been having some problems setting up a many-to-many association using 2 bags (I couldn't delete any elements form my association table without deleting a parent...)
So i wanted to give composite-elements a shot.

I've got a table Changes and another one Modules, linked in a third table ChangesModules.


In my the Module XML I've written:

Code:
    <bag name="Changes" lazy="true" table="ChangesModules">
      <key column="Module"/>
      <composite-element class="Cevi.CeXLS.Hibernate.ChangesModules, Cevi.CeXLS.Hibernate">
        <parent name="Module"/>
        <many-to-one name="Changes" class="Cevi.CeXLS.Hibernate.Changes, Cevi.CeXLS.Hibernate" column="Changes" />
      </composite-element>
    </bag>



In the XML belonging to Changes:

Code:
    <bag name="Modules" table="ChangesModules" lazy="true" inverse="true">
      <key column="Changes"/>
      <composite-element class="Cevi.CeXLS.Hibernate.ChangesModules, Cevi.CeXLS.Hibernate">
        <parent name="Changes"/>
        <many-to-one name="Module" class="Cevi.CeXLS.Hibernate.Module, Cevi.CeXLS.Hibernate" column="Module" />
      </composite-element>
    </bag>



I kept the properties I used during my frustrating exploration of many-to-many associations.
But now I get the following error when I try to fetch aChange.Modules or aModule.Changes:

Failed to lazily initialize a collection.


Changing both to lazy="false" results in the following error:

E = {"could not initialize a collection: [Cevi.CeXLS.Hibernate.Changes.Modules#190][SQL: SELECT modules0_.Changes as Changes__0_, modules0_.Module as Module0_ FROM CeXLS.dbo.ChangesModules modules0_ WHERE modules0_.Changes=?]"}


I hope someone can help me out here ...


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.