-->
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: joining a table to get set keys
PostPosted: Wed Aug 31, 2005 3:11 pm 
Newbie

Joined: Wed Aug 31, 2005 1:20 pm
Posts: 4
Hibernate is great, but I can't come up with a way to accomplish the following: I need to join another table to get the keys for a set. We have three objects: an abstract Account class, a SimpleAccount, and an AggregateAccount. An AggregateAccount is exactly like a SimpleAccount, only it also contains a set of it's subaccounts. The database schema consists of two tables: Accounts, which contains all data for each account, and Aggregates, which maps aggregate accounts (in the Accounts table) to simple accounts (also in the Accounts table).

Here is my mapping file:

Code:
    <class name="Account" table="Accounts" discriminator-value="0">
        <id name="id" column="ID">
            <generator class="identity"/>
        </id>
        <discriminator column="Aggregate" type="integer"/>
        <property name="name"/>
        <property name="shortName"/>
        <subclass name="SimpleAccount" discriminator-value="0" />
        <subclass name="AggregateAccount" discriminator-value="1">
            <set name="subAccounts">
                <key column="ID"/>
                <one-to-many class="Account"/>               
            </set>
        </subclass>
    </class>


I need to be able to essentially join on the Aggregates table to get the Accounts that should be in the subAccounts set in the AggregateAccount subclass. Is there a way to use a key in another table as the collection key? Is there another straight-forward way of doing this?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 31, 2005 3:14 pm 
Newbie

Joined: Wed Aug 31, 2005 1:20 pm
Posts: 4
I'm sorry. This was intended for the Hibernate Users forum.


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.