Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / November 2004

Tip: Looking for answers? Try searching our database.

Hibernate Design-Problem

Thread view: 
Daniel Wotziak - 18 Nov 2004 18:26 GMT
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
jlp - 18 Nov 2004 22:30 GMT
Daniel Wotziak a écrit :
> Hello,
>
[quoted text clipped - 36 lines]
>
>     Daniel
Your problem sounds like the parent/child pattern.
There is an example at the end of Hibernate Reference Manual.
Take a look...


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.