-->
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: Problem mixing "single table" and "table per
PostPosted: Fri Aug 08, 2008 7:06 am 
Newbie

Joined: Fri Aug 08, 2008 6:43 am
Posts: 3
Hello all,

Hibernate version: 3.2

What I want to do is that class B inherits A by "table per class" and C inherits B by "single table".
But JPA/Hibernate generates tables where both inheritance strategies are "table per class". Here is a simplified version:


Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class AbstractObject implements Serializable {
...
}

@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="P_TYPE", discriminatorType=DiscriminatorType.STRING, length=1)
@DiscriminatorValue(value="P")
public class Pet extends AbstractObject implements Serializable {
...
}

@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING, length=1)
@DiscriminatorValue("D")
public class Dog extends Pet {
...
}


What I expect is that hibernate generates db tables AbstactObject and Pet where Pet also has the columns of Dog.
But what hibernate does is to ignore the inheritance annotations of Pet and Dog and generate 3 tables.

I need to keep this object structure as it is generated by another tool. Is there any way to fix this?

Thanks in advance.

PS: Pet and Dog is not my actual object model :) just wanted to make something easy to understand for people who are kind enough to help.


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.