-->
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: Design-Problem: object contains objects of same type...
PostPosted: Thu Nov 18, 2004 2:35 pm 
Newbie

Joined: Thu Nov 18, 2004 2:28 pm
Posts: 1
Hibernate version: version 2.1.6


Hello,

I have a little design-Problem with hibernate.

I have several company-objects. Each company can own several subcompanies. Each company can be owned be several superCompanies. The realationship has an order, that means the super- and the subcompanies are sorted. I can add a superCompany to each company.

So I have two classes:

Company
-------
Members: Id, Name, City, SuperCompanies (Set), SubCompanies (Set)

Methods:
getSubCompanies -> List
getSuperCompanies -> List
addSuperCompany (Company, ordinalNumber)
removeSuperCompany (Company)


CompanyCompany (Relationship-Class)
--------------
Members: SuperCompany, SubCompany, ordinalNumber

If I delete a company, all subCompanies of this company should be delete, too.

How do I realize this using Hibernate? Does the company-class must have two Sets, one for the superCompanies and one for the subCompanies? Do both sets have to be in the mapping-files (company.hbm.xml - two 1:n-relationships, companyCompany.hbm.xml - two n:1 realationships, one for each Set)? How do I have to set the cascading-attribute, so that if I delete one company, all subCompanies are deleted, too? Is there a mistake in my logical sequence of thoughts?

Many thanks in advance for your help!

Daniel


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.