0 Replies Latest reply on Jun 1, 2007 2:13 PM by Bruno Beloff

    Bug in JBoss EJBQL Implementation?

    Bruno Beloff Newbie

      Hi

      I have an EJBQL finder that appears to produce the incorrect result when deployed on JBoss 4.0.2. I wonder if anyone would like to comment on this: perhaps this is a know bug, maybe there is a work-around, or maybe I'm doing something wrong.

      The situation: I have three entity beans: Course, Product and Group. There is a many-to-many relationship between Course and Group, and between Product and Group.

      I have three finders:

       <query>
       <query-method>
       <method-name>findWithCourses</method-name>
       <method-params>
       <method-param>java.lang.String</method-param>
       </method-params>
       </query-method>
       <ejb-ql><![CDATA[SELECT OBJECT(g) FROM GroupSchema g WHERE (g.school.id = ?1) AND (g.courses IS NOT EMPTY)]]></ejb-ql>
       </query>
      


      This correctly returns all the Groups that have at least one Course member.

       <query>
       <query-method>
       <method-name>findWithProducts</method-name>
       <method-params>
       <method-param>java.lang.String</method-param>
       </method-params>
       </query-method>
       <ejb-ql><![CDATA[SELECT OBJECT(g) FROM GroupSchema g WHERE (g.school.id = ?1) AND (g.products IS NOT EMPTY)]]></ejb-ql>
       </query>
      


      This correctly returns all Groups that have at least one Product member.

      However:

       <query>
       <query-method>
       <method-name>findNonEmpty</method-name>
       <method-params>
       <method-param>java.lang.String</method-param>
       </method-params>
       </query-method>
       <ejb-ql><![CDATA[SELECT OBJECT(g) FROM GroupSchema g WHERE (g.school.id = ?1) AND ((g.courses IS NOT EMPTY) OR (g.products IS NOT EMPTY))]]></ejb-ql>
       </query>
      


      I believe that this should return all Groups that have EITHER at least one Course member OR at least one Product member.

      But it doesn't! It returns only the Groups that have BOTH at least one Course member AND at least one Product member.

      Does anyone have any ideas?

      Bruno Beloff.