-->
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: Mixing inheritance strategies
PostPosted: Thu Jan 03, 2008 9:11 pm 
Newbie

Joined: Thu Jan 03, 2008 5:05 pm
Posts: 2
Hi, my name is Rogerio. I´m facing a problem with mixing inheritance strategies. I already have searched on the web for examples, tutorials, etc, but i did not have found a sample that shows the same mixing that i have trying. I have this:

A ---
/ \ \
B C F
/ \ | \
D E G H


The mapping is this:

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@PrimaryKeyJoinColumn(name="NUMG_A")
@Table(name="table_A")
public abstract class A extends MappedEntity {
...
}

@Entity
@Table(name = "table_C")
@PrimaryKeyJoinColumn(name = "NUMG_C")
public class C extends A {
...
}


@Entity
@Table(name = "table_B")
@PrimaryKeyJoinColumn(name = "NUMG_B")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = B.DISCRIMINATOR_FIELD, discriminatorType = DiscriminatorType.INTEGER)
public abstract class B extends A {
...
}

@Entity
@DiscriminatorValue("D")
public class D extends B {
...
}

@Entity
@DiscriminatorValue("E")
public class E extends B {
...
}

@Entity
@Table(name = "table_F")
@PrimaryKeyJoinColumn(name = "NUMG_F")
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class F extends A {
...
}

@Entity
@Table(name = "table_G")
@Inheritance(strategy = InheritanceType.JOINED)
@PrimaryKeyJoinColumn(name = "NUMG_G")
public class G extends F {
...
}

@Entity
@Table(name = "table_H")
@Inheritance(strategy = InheritanceType.JOINED)
@PrimaryKeyJoinColumn(name = "NUMG_H")
public class H extends F {
...
}


I´m having problem on query for a list of A entities. The problem is that hibernate is joinning the B's subclasses when it must use the discriminator value. I saw something about a SecondaryTable but i could not find some example to solve my problem. Can anyone help me?

Thanks.


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.