-->
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: [b]How to map a list of abstract classes?[/b]
PostPosted: Thu Dec 09, 2004 9:51 am 
Newbie

Joined: Thu Dec 09, 2004 9:35 am
Posts: 2
Hibernate version:2.1.4

This is a legacy environment(no domain and data model changes are allowed) and I am in the process of implementing hibernate to replace existing home-grown ORM solution

I have the following classes
Code:
1. public class abstract  LocatableItem{...}
2. public class Building extends LocatableItem {...}
3. public class Equipment extends LocatableItem {...}
4. public class Location {
        List locatableItems;
        void  setLocatableItems(List locatableItems) {
               this.locatbleItems = locatableItems;
        }
    }

And I have the following tables
    1. Location
    2. Building with foreign key relationship to Location
    3. Equipment with foreign key relationship to Location


I would appreciate any ideas to map the Location table.

Thank you.
DR.[/list]


Top
 Profile  
 
 Post subject: Re: How to map a list of abstract classes
PostPosted: Thu Dec 09, 2004 4:58 pm 
Newbie

Joined: Thu Dec 09, 2004 9:35 am
Posts: 2
This is how I managed to map the relationships.
Code:
<class name="Location" ...>
   <list  name="locatableItems_Building"
          table="BUILDING"
          ..
          <one-to-many to Building class/>
   </list>
   <list name="locatableIems_Equipment"
           table="EQUIPMENT"
           ..
           <one-to-many to Equipment class/>
   </list>
</class>


In Location domain class, introduced two lists: locatableItems_Building and locatableItems_Equipment. Also made the necessary changes in setLocatableItems() and getLocatableItems() in Location to retrieve actual objects(Building or Equipment) and populate locatableItems.


Any suggestions or other ideas would be appreciated.

Thanks,
DR


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.