2 Replies Latest reply on May 3, 2006 2:32 PM by Stephen McCants

    EJB3 Inheritance complains about a parent's collection

    Stephen McCants Newbie

      Hello All,

      Ran into a strange problem (not really sure what is wrong) when I tried to extend a working Entity Bean. The extended Entity Bean complains about a collection in its parent class.

      Here is the error message:

      org.hibernate.AnnotationException: Collection of elements must not have mappedBy or association reference an unmapped entity: TrackedItem.userData


      Here is TrackedItem:

      @Entity
      @Inheritance(strategy=InheritanceType.JOINED)
      @DiscriminatorValue(value = "I")
      public class TrackedItem implements Serializable
      {
      ....
       @OneToMany(mappedBy="item", cascade = {CascadeType.ALL})
       @MapKey(name="key")
       private Map<String, UserDatum> userData;
      }


      Here is UserDatum:

      @Entity
      public class UserDatum implements Serializable {
      ...
       private String key;
       @ManyToOne
       private TrackedItem item;
      }
      

      Here is Fail which extends TrackedItem:

      @Entity
      @DiscriminatorValue(value = "S")
      public class Fail extends TrackedItem {
      ....
      }


      Fail doesn't contain any collections or references to userData or UserDatum.

      When I deploy TrackedItem and UserDatum everything deploys cleanly, works fine and my unit tests pass. When deploy Fail, I get the error message above as the reason the deployment failed.

      Any help is appreciated!

      Sincerely,

      Stephen