0 Replies Latest reply on Jul 13, 2007 7:10 AM by Dennis M Pettersson

    mappedBy and inheritance

    Dennis M Pettersson Newbie

      I have a problem with extending entity classes and OneToMany relations.
      (The problem is not the same as http://jboss.com/index.html?module=bb&op=viewtopic&t=111688)

      My superclass, Inventory, has a column, station, which is used to map a relation with the Station entity

      public class Station implements Serializable {
       @OneToMany(cascade = ALL, mappedBy = "station")
       private Set<InventoryType1> inventory1 = new HashSet<InventoryType1>(0);
      }
      
      public class Inventory implements Serializable {
       /** Station */
       @ManyToOne
       @JoinColumn(name = "station_id")
       private Station station;
      }
      
      public class InventoryType1 extends Inventory implements Serializable {
      }
      

      This fails with a
      org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: Inventory1.station in Station.inventory1

      As Inventory1 has no station column. In my opinion is has, as it inherits the columns of Inventory.
      I could probably work around this by moving the station_id to each sub entity, but it really belongs in the super class as it's common for all Inventory types.