-->
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.  [ 2 posts ] 
Author Message
 Post subject: Many to many result too big
PostPosted: Mon Mar 12, 2007 6:45 am 
Beginner
Beginner

Joined: Sun Oct 22, 2006 12:06 pm
Posts: 39
Hi!
I'm in the problem in many-to-many relation beacause Hibernate return's too many object instances


I have 3 tables mapped as:


Code:
<class name="Ankeet" table="ankeet" lazy="false">
        <id name="id" column="id" type="long" >
            <generator class="sequence">
                <param name="sequence">seq_ankeet</param>
            </generator>
        </id>
        <property name="name"  type="java.lang.String" column="name" />
        <bag name="tegevusedList" table="ankeet_tegevus_aspekt">
            <key column="ankeet" />     
            <many-to-many class="Tegevus" column="tegevus"/>
        </bag>
        <bag name="apektList" table="ankeet_tegevus_aspekt">
            <key column="ankeet" />     
            <many-to-many class="Aspekt" column="aspekt"/>
        </bag>       
    </class>
     <class name="Tegevus" table="tegevus" lazy="false">
        <id name="id" column="id" type="long" >
            <generator class="sequence">
                <param name="sequence">seq_tegevus</param>
            </generator>
        </id>
        <property name="name"  type="java.lang.String" column="name" />       
       <bag name="ankeedidList" table="ankeet_tegevus_aspekt">
            <key column="tegevus"/>
            <many-to-many class="Ankeet" column="ankeet"/>
        </bag>
        <bag name="aspektList" table="ankeet_tegevus_aspekt">
            <key column="tegevus" />     
            <many-to-many class="Aspekt" column="aspekt"/>
        </bag>
    </class>
    <class name="Aspekt" table="aspekt" lazy="false">
        <id name="id" column="id" type="long" >
            <generator class="sequence">
                <param name="sequence">seq_aspekt</param>
            </generator>
        </id>
        <property name="name"  type="java.lang.String" column="name" />       
        <bag name="ankeetList" table="ankeet_tegevus_aspekt">
            <key column="aspekt"/>
            <many-to-many class="Ankeet"/>
        </bag>       
        <bag name="tegevusList" table="ankeet_tegevus_aspekt">
            <key column="tegevus"/>
            <many-to-many class="Tegevus"/>
        </bag>       
    </class>


So every table has many to many relations to each other
and are bound together in one table ankeet_tegevus_aspekt
And in ankeet_tegevus_aspekt table there is data like this:

Code:
Aspekt   |Ankeet   |Tegevus
8      |116   |11
9      |116   |11
8      |116   |12

By loading the ankeet there is
3 instances of tegevus not 2
Ankeet[0] (tegevus count(3))
- Tegevus (id:11)
- Tegevus (id:11)
- Tegevus (id:12)

How should I write the query that ankeet instance would group it's tegevus data, that I could get the result like
Ankeet[0] (tegevus count(2))
- Tegevus (id:11)
- Tegevus (id:12)[/code][/list]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 12, 2007 7:59 am 
Beginner
Beginner

Joined: Sun Oct 22, 2006 12:06 pm
Posts: 39
OK resolved that.
It made things too complicated, so I decided to drop those many to many relations and load all the object hierarchy in BusinessObject in recursive mode.


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

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.