1 Reply Latest reply on Mar 25, 2002 8:39 AM by ObjectWiz

    Can EJB's reference their own class?

    ObjectWiz Newbie

      Hi all,

      I have posted a similar message to the EJB forum before and got nothing in response so can I ask *please* for some help on this... :-)

      I have a bean called Message that I want to have both parent Messages and child Messages - i.e. build a hierarchy of Message objects. I have written the bean using XDoclet 1.1.2 CMP 2.0 and tried to deploy to both JBoss 3.0 CVS and Orion. Orion is fine but JBoss gives the following:

      nested throwable is: org.jboss.deployment.DeploymentException: Atleast one role of a foreign-key mapped relationship must have key fields: ejb-relation-name=parent

      So... does a relationship really need to have a primary or foreign key field? If so, does this mean a Message bean can't reference itself?



        • 1. Is CMP 2.0 really working?
          ObjectWiz Newbie

          Hi All,

          I have solved the problem of JBoss not allowing me to deploy by specifying a related-pk-field in the @jboss:relation tag in xdoclet (post: Can EJB's reference their own class?). Now I have other problems... :-)

          1) The relationship is supposed to be bi-directional... I thought if I called setParent() on a Message, it would also add the child to the collection of children. It doesn't...

          2) JBoss returns null if I call getChildren() when there are no children. I can't call add() therefore and creating my own collection and calling setChildren() doesn't work...

          3) Orion does one direction but not both, i.e. I can setParen() and parent is set but children aren't added. I can add a child (as I get a *real* Collection back not null) but it doesn't set the parent.

          Am I missing something obvious here? At least in Orion if I call x.setParent(y); y.addChildren(x); I get the result I want even if it should (AFAIK) be automated by calling either method. JBoss fails to do either.