-->
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.  [ 8 posts ] 
Author Message
 Post subject: SchemaExport with Inheritance Type of TABLE_PER_CLASS
PostPosted: Thu Apr 28, 2005 11:16 am 
Newbie

Joined: Thu Oct 28, 2004 1:26 pm
Posts: 5
Hibernate version: Hibernate 3.0.2. Hibernate Tools 3.0, Hibernate Annotations 3.0 b1

Name and version of the database you are using: MySql 4.1

I am attempting to do some simple inheritance utilizing Hibernate 3.0.1, Hibernate Tools 3.0, and Hibernate Annotations 3.0 beta 1.

My sample code goes something like this:
I have a Person class, and an Employee Class, Employee extends Person, and I want to utilize the Table-per-class Inheritance Type :

Code:
@Entity()
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS )
@Table(name="PERSON")
public class Person implements Serializable {

....

@Entity()
@Table(name="EMPLOYEE")
public class Employee extends Person implements Serializable {



When I export the schema for these two classes, I get one PERSON table with all the attributes of Person and Employee. No EMPLOYEE table is generated.

I have tried modifying the code in many ways, including moving the Inheritance Annotation to Employee and removing it from Person, to no avail (that actually throws an exception). I have also tried various other things to fix this problem to no avail.

Is the TABLE_PER_CLASS inheritance strategy not supported by the schema exporter or annotations or what?

Any help would be appreciated.

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 28, 2005 11:18 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
InheritanceType.JOINED


I'm trying to get this naming fixed in the ejb spec.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 28, 2005 12:34 pm 
Newbie

Joined: Thu Oct 28, 2004 1:26 pm
Posts: 5
So are you saying that InheritanceType.TABLE_PER_CLASS is not supported yet?

In this example, I want 2 tables generated, one EMPLOYEE table and one PERSON table.
EMPLOYEE would contain everything that PERSON contained plus any extra attributes I tack on.


gavin wrote:
InheritanceType.JOINED


I'm trying to get this naming fixed in the ejb spec.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 29, 2005 11:08 am 
Newbie

Joined: Fri Apr 29, 2005 10:43 am
Posts: 2
We are trying to use this feature as well. My understanding is that annotation "InheritanceType.TABLE_PER_CLASS" is equivalent to xml mapping <union-subclass>.

We did successfully with <union-subclass> by using mapping file but failed on "TABLE_PER_CLASS" by using annotation-hibernate tool- schema generation.

We tried "InheritanceType.JOINED" successfully. However, we really want to use "InheritanceType.TABLE_PER_CLASS" for our top-level inheritance classes...

So, is InheritanceType.TABLE_PER_CLASS currently supported? or we are using something wrong? Please clarify this if possible, thanks!

-kk

_________________
- kk


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 02, 2005 5:54 pm 
Newbie

Joined: Thu Oct 28, 2004 1:26 pm
Posts: 5
Did you get any answers on this? This is a very frustrating problem, I would prefer not to use a Joined Subclass...


kknd22 wrote:
We are trying to use this feature as well. My understanding is that annotation "InheritanceType.TABLE_PER_CLASS" is equivalent to xml mapping <union-subclass>.

We did successfully with <union-subclass> by using mapping file but failed on "TABLE_PER_CLASS" by using annotation-hibernate tool- schema generation.

We tried "InheritanceType.JOINED" successfully. However, we really want to use "InheritanceType.TABLE_PER_CLASS" for our top-level inheritance classes...

So, is InheritanceType.TABLE_PER_CLASS currently supported? or we are using something wrong? Please clarify this if possible, thanks!

-kk


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 03, 2005 4:05 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It is true that Hibernate annotations does not handle table_per_class correctly: you have to put this annotations on the leaves in your class hierarchy.
But, table_per_class does not mean you will have a Person table and an employee table refering the same data. It means you will have an Employee (and maybe an Employer) table containing all the columns.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 03, 2005 10:12 am 
Newbie

Joined: Thu Oct 28, 2004 1:26 pm
Posts: 5
Emmanuel -
Thanks for the response.
I understande what you are saying about the table data, and that is fine. I just wanted to verify that the annotations or the SchemaExporter did not handle the Table per class strategy correctly.
If I put the Table per class annotation on a leaf node, I get a stack trace anyway.

I just wanted to a) make sure that I am not doing something wrong and b) see if this would be fixed any time soon.

Thanks

emmanuel wrote:
It is true that Hibernate annotations does not handle table_per_class correctly: you have to put this annotations on the leaves in your class hierarchy.
But, table_per_class does not mean you will have a Person table and an employee table refering the same data. It means you will have an Employee (and maybe an Employer) table containing all the columns.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 8:58 pm 
Regular
Regular

Joined: Sun Sep 26, 2004 9:27 pm
Posts: 75
Location: Atlanta, GA, USA
juice wrote:
Emmanuel -
Thanks for the response.
I understande what you are saying about the table data, and that is fine. I just wanted to verify that the annotations or the SchemaExporter did not handle the Table per class strategy correctly.
If I put the Table per class annotation on a leaf node, I get a stack trace anyway.

I just wanted to a) make sure that I am not doing something wrong and b) see if this would be fixed any time soon.

Thanks

emmanuel wrote:
It is true that Hibernate annotations does not handle table_per_class correctly: you have to put this annotations on the leaves in your class hierarchy.
But, table_per_class does not mean you will have a Person table and an employee table refering the same data. It means you will have an Employee (and maybe an Employer) table containing all the columns.


Is this still the case? Is TABLE_PER_CLASS still not handled correctly using the following:

Core 3.2 CR2
Annotations 3.2 CR1
EntityMgr 3.2 CR1
Tools 3.1 beta 5


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