0 Replies Latest reply on Nov 23, 2002 6:49 PM by arnaudjamin

    recursive relation :  ElementBean-1---N-ElementBean

    arnaudjamin

      Hello,
      I'd like to know if it's possible to have a 1-N relation in the same Entity. The goal is it create a tree : ElementBean-1-----N-ElementBean
      I tried the followin is my ElementBean :


      /**
      * @ejb:interface-method view-type="local"
      *
      * @ejb.relation
      * name="parent-element"
      * role-name="element-has-a-parent"
      *
      * @jboss.relation-mapping style="foreign-key"
      *
      * @jboss.relation
      * fk-constraint="true"
      * fk-column="parent_fk"
      * related-pk-field="id"
      **/
      public abstract ElementLocal getParent();
      /**
      * @ejb:interface-method view-type="local"
      */
      public abstract void setParent(ElementLocal parentId);


      /**
      * @ejb.interface-method view-type="local"
      *
      * @ejb.relation
      * name="parent-element"
      * role-name="parent-has-children"
      *
      * @jboss.relation-mapping style="foreign-key"
      *
      */
      public abstract java.util.Collection getChildren();
      /**
      * @ejb:interface-method view-type="local"
      */
      public abstract void setChildren(java.util.Collection children);


      But i get the error :

      [ServiceController] Problem starting service jboss.j2ee:jndiName=oedl/User,service=EJB
      org.jboss.deployment.DeploymentException: CMP field for key not found: field name=id
      at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCRelationshipRoleMetaData.loadKeyFields(JDBCRelationshipRoleMetaData.java:374)
      ....
      [ServiceController] Problem starting service jboss.j2ee:jndiName=oedl/Element,service=EJB
      org.jboss.deployment.DeploymentException: CMP field for key not found: field name=id
      ....

      (this message appears with all my EJB names)

      Thanks.