-->
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: Composite elements may contain components but ! collections.
PostPosted: Mon Jun 07, 2004 8:50 pm 
Beginner
Beginner

Joined: Thu Nov 20, 2003 8:13 pm
Posts: 31
Location: Newport Beach, CA
Composite elements may contain components but not collections.

Though it is easy to work around, I am curious why this limitation exists.

Reference object model:

Company *---* State 1---* County

Code:
Company
  Collection<CompanyState>

CompanyState
  State state
  int weight
  Collection<CompanyCounty>

CompanyCounty
  County county
  int weight


Each company does business in a Collection of States, represented by CompanyState, with a piece of information (weight) relevant to their business in that state. Some companies are further restricted to business in particular counties within their states, represented by CompanyCounty, again with a piece of information (weight) relevant to their business in that county.

This would map very nicely as a Collection of composite-elements on Company with the elements each having their own nested Collection members (pseudo-code):

Code:
        <class name="Company" table="company">
            <key column="company_no"/>

            <set name="companyStates" table="comp_state">
                <key column="company_no"/>

                <composite-element class="CompanyState">
                    <property name="weight" type="integer"/>

                    <many-to-one name="state" column="state_no"
                        class="State"/>

                    <set name="companyCounties" table="comp_county">
                        <key column="company_no"/>
                        <key column="state_no"/>

                        <property name="weight" type="integer"/>

                        <many-to-one name="county" class="County"/>
                    </set>
                </composite-element>
            </set>
        </class>


The construct:
Code:
                    <set name="companyCounties" table="comp_county">
                        <key column="company_no"/>
                        <key column="state_no"/>
...
                    </set>



is not legal. Is this why we cannot have a Collection in a composite-element? Because there is no way to indicate a composite id for Collections?

Thx for any input
Justin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 08, 2004 1:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This would be very complex to implement. Nested collections like this requires a complex garbage collection algorithm.

You are better off just remodelling the composite element as a collection.


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.