2 Replies Latest reply on Jul 16, 2006 11:15 AM by andy

    Deployment error mapping a parent/child related entity

    andy Newbie

      I have a self-referencing entity hierarchy like that:

      @Entity
      @Inheritance(strategy=InheritanceType.JOINED)
      public abstract class HrcEntity<T extends HrcEntity> extends ComplexEntity
      {
       private List<T> children;
       private T parent;
      
       @OneToMany(mappedBy="parent", cascade=CascadeType.REMOVE)
       public List<T> getChildren()
       {
       return children;
       }
      
       @ManyToOne(fetch=FetchType.LAZY)
       public T getParent()
       {
       return parent;
       }
      
      }
      
      @Entity
      @Inheritance(strategy=InheritanceType.JOINED)
      public class Node extends HrcEntity<Node>
      {
       ...
      }


      so I can do for example:

      List<Node> children = node.getChildren();


      but deploying these entities I get the error:
      "java.lang.IllegalStateException: Property parent has an unbound type and no explicit target entity."

      from my point of view this should work - there is is a table HrcEntity in db and hibernate simply has to map the column "parent" to the same table.

      btw. - if I make HrcEntity non-generic it works, but I get very ugly code with lot of casts and "instanceof"

      any comments? thanks!