[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Bug in JBoss EJBQL Implementation?

bbeloff do-not-reply at jboss.com
Fri Jun 1 14:13:34 EDT 2007


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.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4050578#4050578

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4050578



More information about the jboss-user mailing list