-->
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.  [ 3 posts ] 
Author Message
 Post subject: Classes implementing multiple interfaces
PostPosted: Thu Dec 11, 2003 12:33 pm 
Beginner
Beginner

Joined: Thu Dec 11, 2003 11:59 am
Posts: 24
Let's say that I have 3 interfaces:
Colour
- getColour/setColour
Position
- getX/setX
- getY/setY
Size
- getSize/setSize

I have different classes that implement 1, 2, or all 3 of the interfaces.

How do I get Hibernate to represent this structure? I would like to be able to do something like:

Code:
<class name="Colour" ...>
  ...
  <joined-subclass name="A" ...>
    ...
</class>
<class name="Position" ...>
  ...
  <joined-subclass name="A" ...>
  ...
</class>
<class name="Size" ...>
  ...
  <joined-subclass name="A" ...>
  ...
</class>


I would prefer to use <joined-subclass> because the interfaces used in my project have many more "attributes" than the interfaces in this example.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 11, 2003 7:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Please refer to the new page on "Inheritance Mappings" in the Hibernate 2.1 final download.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 11:03 am 
Beginner
Beginner

Joined: Thu Dec 11, 2003 11:59 am
Posts: 24
Thanks for the pointer. That page definitely helps clarify a few things.

It seems like I can't set up the tables exactly as I'd like to, so I'm going to propose a future enhancement to the per-subclass strategy: table per subclass and interface. Each interface gets its own table which is referenced by the tables of classes or subclasses that implement it. In my example, it would result in the following tables and columns:

Colour
- key
- colour
Position
- key
- x_coordinate
- y_coordinate
Size
- key
- size
A
- id
- colour_key
- position_key
- size_key

As long as the interfaces don't define getId/setId, I think that it should work.

What do you think?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.