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.
|