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