3 Replies Latest reply on Sep 8, 2006 9:46 AM by Brett Birschbach

    SINGLE_TABLE Inheritance and relations

    Frédéric EECKHOUT Newbie

      I'm using JBoss 4.0.4CR2

      I have an Entity A and an Entity B.
      B1 and B2 extend B with SINGLE_TABLE InheritanceType (with a discriminator column).
      A has some B1 and some B2 : I have two relations OneToMany between A and B1, and A and B2.
      These relations are mapped by the same field on B with a reference on A :
      one relation ManyToOne B-A mapping 2 relations OneToMany A-B1 and A-B2.
      I prefere having the same field on B, because all classes extending B have this relation, I won't create a new mapping field for each Bx.

      When I try to get all B1 from entity A, jboss try to get all B's from database, and then throws an Exception because it sees that a record are not B1, but B2.

      I think that when I call the getter method (getB1), it make only check on mapping field, but not on Inheritance DiscriminatorColumn "type".

      How can I make it works ?

      Thanks.