-->
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: mapping object hierarchy with @Inheritance(strategy=JOINED)
PostPosted: Tue Mar 13, 2007 9:40 am 
Newbie

Joined: Wed Feb 01, 2006 10:45 am
Posts: 18
Location: Salzburg, Austria
Hi all,

i'm trying to map following object tree with table per class hierarchy
AND Joined subclasses strategy, but i always get table per class
hierarchy

Code:
A(name) -> B1(name)
        -> B2(name)
        -> B3(name) -> C1(ref)
                    -> C2(type)


so i defined my classes as :

Code:
@Entity
@DiscriminatorColumn(
        name="access_type",discriminatorType=DiscriminatorType.STRING
    )
@DiscriminatorValue("a-type")
@Table(name="a")
public abstract class A  { ... }


B1 and B2 are straight forward:

Code:
@Entity
@DiscriminatorValue("b1")
public class B1 extends A  { ... }

@Entity
@DiscriminatorValue("b2")
public class B2 extends A  { ... }


as i want to have separate tables for C1 and C2
i add @Inheritance(strategy=InheritanceType.JOINED)
to my B3 object

Code:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class B3 extends A  { ... }


C1 and C2 then extend from B3
Code:
@Entity
public abstract class C1 extends B3  { ... }

@Entity
public abstract class C2 extends B3  { ... }


When i test this i always get a single table for both hierarchies (B and C)
because the discriminator is inherited from the base class A.

Is there a way i can save my C objects in separate tables?
After reading the documentation i'm wondering whether i should use a @SecondaryTable, or a @OneToOne, or even @MappedSuperclass

I'd appreciate any hint :)
Thank you!

g,
kris

Hibernate version:
3.2.1.ga

Name and version of the database you are using:
HSQLDB 1.8.0.7

_________________
greetings,
kris


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 13, 2007 6:49 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you can map that using a @SecondaryTable(s)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 6:33 am 
Newbie

Joined: Wed Feb 01, 2006 10:45 am
Posts: 18
Location: Salzburg, Austria
thank you, i'll try this...

_________________
greetings,
kris


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.