-->
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: Interfaces and Multiple-inheritence
PostPosted: Wed May 23, 2007 6:42 am 
Newbie

Joined: Mon Mar 05, 2007 8:53 am
Posts: 2
Hi,
I've got an object model that makes use of interfaces to provide me effectively with multipe inheritence.

I have the following classes.
  • IContext (interface)
    • Location implements IContext
    • Person implements IContext
  • User
  • UserContext ( maps User to IContext )


My IContext represents a "sphere of influence" for a user. Therefore, if I have control of an IContext I have control over it's children. A Location's children are sub-locations (e.g. UK => England => London => Warehouse => Storeroom), and a Person's children are their sub-ordinates (e.g. MD => Director => Manager => Employee => Cleaner => Mouse => Software Developer *joke*).

To do this I've created a mapping:
Code:
<hibernate-mapping ... >

  <class name="IContext">
    <id>...</id>
  </class>

  <joined-subclass name="Location" extends="IContext">
    <key column="Id" />
    ...
  </joined-subclass>

  <joined-subclass name="Location" extends="IContext">
    <key column="Id" />
    ...
  </joined-subclass>

  <class name="User">
    <id>...</id>
    <bag name="Contexts" ... >
      <key column="User"/>
      <one-to-many class="UserContext" />
    </bag>
  </class>

  <class name="UserContext">
    <id>...</id>
    <many-to-one name="User" type="User" ... />
    <many-to-one name="Context" type="IContext" ... />
  </class>

</hibernate-mapping>

This all works well and I'm able to use IContext to map across a diverse set of objects to model them in a common fashion. The problem I run into is that Location and Person need to implement some other interfaces, which I also need to operate in a similar fashion to IContext. At this point I run into a problem because I can only extend a single class or interface, also a class implementing IContext may already have a parent class that isn't an IContext.

Does anyone have any ideas regarding this problem?
Would implementing a new IClassPersister to handle interfaces be a decent solution? If so, has anyone already written one? I ask this in complete ignorance of IClassPersister as I've not looked into it yet.


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.