-->
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: Table per subclass with table per class hierarchy
PostPosted: Sun Jul 13, 2008 9:55 am 
Newbie

Joined: Fri Jun 30, 2006 12:11 am
Posts: 7
Location: Pune
Hi,

I am facing an issue with mixed inheritance. Table per subclass with table per class hierarchy is being used.
Code:
                                         A
                                         | 
                                      ____   (Table per subclass)
                                     |       |
                                    B       C
                                              |
                                            ___   (Table per class hierarchy)
                                           |     |
                                           D    E


Class A is the superclass which has class level annotations as



@Entity()
@Table(name = "TABLE_A")
@Inheritance(strategy = InheritanceType.JOINED)
public [b]abstract[/b] class A {
....
}

Annotations for class B are

@Entity
@Table(name = "TABLE_B")
@PrimaryKeyJoinColumn(name = "B_ID", referencedColumnName = "A_ID")
public class B {
....
}

Annotations for class C are
@Entity
@Table(name = "SINGLE_TABLE_C")
@PrimaryKeyJoinColumn(name = "C_ID", referencedColumnName = "A_ID")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="C_TYPE", discriminatorType=DiscriminatorType.INTEGER)
public [b]abstract[/b] class C {
....
}

Annotations for class D are
@Entity
@DiscriminatorValue(value = "1")
public class D {
...
}

Annotations for class E are
@Entity
@DiscriminatorValue(value = "2")
public class E {
...
}

There are 5 tables getting created (TABLE_A, TABLE_B, SINGLE_TABLE_C, D and E) instead of only three (TABLE_A, TABLE_B, SINGLE_TABLE_C).

Can anyone please guide on this

Thanks in advance
[/code]


Top
 Profile  
 
 Post subject: Table per subclass with table per class hierarchy
PostPosted: Sat Jul 19, 2008 10:00 am 
Newbie

Joined: Fri Jun 30, 2006 12:11 am
Posts: 7
Location: Pune
Any suggestions on this topic? Any links or guidance would be appreciated.

Thanks in advance


Top
 Profile  
 
 Post subject: Re: Table per subclass with table per class hierarchy
PostPosted: Sat Jun 25, 2011 4:57 am 
Newbie

Joined: Sat Jun 25, 2011 4:51 am
Posts: 1
Question to the author: did you solved this problem? If yes, please, share the solution.


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.