-->
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.  [ 5 posts ] 
Author Message
 Post subject: Mixing Inheritance Strategies
PostPosted: Sat Jun 11, 2005 5:44 am 
Newbie

Joined: Fri Jun 10, 2005 3:33 pm
Posts: 3
Hi,

I want to mix multiple inheritance strategies in a single inheritance graph and can't figure how to do this. I have:

class Item {
...
}

class Product extends Item {
...
}

class ClothingProduct extends Product {
...
}

and would like Product to be a JOINED-subclass while ClothingProduct uses SINGLE_TABLE mode sharing the table with Product. I can't figure out how to denote this correctly. It seems the InheritanceType.JOINED is automatically mapped to all subclasses. Is mixing InheritanceType not allowed when using annotations?


Top
 Profile  
 
 Post subject: Almost forgot...
PostPosted: Tue Jun 14, 2005 3:57 pm 
Newbie

Joined: Fri Jun 10, 2005 3:33 pm
Posts: 3
... I am using Java 5 annotations (or trying to)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 8:58 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
a Hint
A joined subclass is equivalent to a subclass having a secondary table.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 5:20 am 
Newbie

Joined: Fri Jun 10, 2005 3:33 pm
Posts: 3
Sorry I think I didn't make myself clear enough:
I am using:

Hibernate 3.05
Annotations beta 2
MySQL 4.0 with InnoDB


and would expect this:

@Entity
public class Item {
...
}

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Product extends Item {
...
}

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
SpecialProduct extends Product {
...
}

to generate 2 tables (item and product) but it also generates a specialproduct table. Now the question is: How do I make SpecialProduct share the table with Product while keeping Product a joined subclass of Item?

Thanks for your time

Krow


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 5:33 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I understood you correctly. As I already said, you can achieve that using a SINGLE_TABLE strategy and appropriatly use the notion of @SecondaryTable. I can't say much because it's hard to explain on a forum.
Check this material too http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#inheritance-mixing-tableperclass-tablepersubclass

_________________
Emmanuel


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