0 Replies Latest reply on May 1, 2003 1:21 PM by Luiz-Otavio Zorzella

    How to have a recursive EJB-QL

    Luiz-Otavio Zorzella Newbie

      Say I have a MyBean "A" that has a PK "guid", and may or not have a parent of the same kind MyBean.

      Is there a EJB-QL to find if either "A" or it's parent, or it's parent parent, etc, has a certain primary key?

      I tried used a half-baked solution, where I artificially limited the nesting to two levels:

      SELECT a.guid from MyBeans as a WHERE a.guid = ?1 OR a.parent.guid = ?1 OR a.parent.parent.guid = ?1

      Even this won't work, because if "a" does not have a parent or a grandparent, the SQL query produced will leave it out.

      Zorzella