-->
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: Mixed table inheritance
PostPosted: Wed Nov 02, 2005 6:02 am 
Newbie

Joined: Wed Nov 02, 2005 5:44 am
Posts: 4
I have a complex object inheritance structure as follows:

- A super class called Base.
- 4 sub classes called A, B, C, and D.
- C and D has more sub classes called C1, C2, C3, and D1

I want to have A in one table, B in one table, C & C1 & C2 & C3 in one table, and D & D1 in one table.

The first obvious solution is to not mark the Base super class with any annotations, just let it be an standard abstract class. All others are annotated with @Entity. Then we annotate the C* and D* classes with the @Inheritance annotation with the inheritance type SINGLE_TABLE.

This works fine.

But here is the problem. The super class has a number of attributes that should be persisted. To make them actually be persisted, I have to override all the getters in the A, B, C, and D classes and annotate them (with @Id, @Column, @OneToOne, @JoinColumn, and so on...). So instead of just having the attributes in the super class I have to duplicate them in the sub classes.

Is there a way for me to solve this? Just to annotate the super class with @Entity does not work.

Thanks
/Patrik


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 03, 2005 7:06 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@EmbeddeableSuperclass

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 03, 2005 7:21 am 
Newbie

Joined: Wed Nov 02, 2005 5:44 am
Posts: 4
Aha! Thank you.

I can't find it anywhere in the documentation. And the javadoc doesn't say anything. Where can I read about it?

/Patrik


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 03, 2005 7:30 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/#d0e656

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 03, 2005 7:34 am 
Newbie

Joined: Wed Nov 02, 2005 5:44 am
Posts: 4
Ok, sorry. I searched that document for the spelling EmbeddeableSuperclass (as you said). But in the docs the spelling is EmbeddableSuperclass.

Thank for all help. It solved my problem perfectly!

Best regards,
patrik


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.