-->
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: Bottom-up Mapping for a Hierarchical Entity Relationship
PostPosted: Thu Apr 07, 2005 5:44 pm 
Newbie

Joined: Thu Apr 07, 2005 3:58 pm
Posts: 2
Hello, and thanks in advance for your time and assistance...

Synposis:
* Need a mapping for a hierarchical (recursive) relationship.
- Using hibernate 2.
- Hand-mapping the relationships absent from Middlegen-generated hbm's for an existing database.

Details:
The database schema tries to model a hierarchical relationship with a link table whose two columns are the parent and child id's, respectively. These id's are foreign keys to the entity primary key. For example, there is an Account entity with PK, AccountId. There is also an association table, AccountHierarchy, with columns ParentAccountId and ChildAccountId, each of which references AccountId (they "are" AccountId's).

If I was going top-down, I might have created a class Account not unlike the following:

class Account {
Account parent; // the parent Account
List children; // or whatever collection of child Accounts
...
}

Somehow I don't get the mapping I'm looking for with my (expanding) knowledge of hibernate. Other link tables were easy to map in the usual ways, for example, as bi-directional many-to-many's. So am I making too much out of this, in that I can't reason through how to implement this mapping?

Regards,
- James

P.S.
You all do great work that is appreciated, even by newbies such as myself!


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.