[ http://jira.jboss.com/jira/browse/JBAS-1263?page=history ]
Scott M Stark reassigned JBAS-1263: ----------------------------------- Assign To: Alexey Loubyansky (was: Scott M Stark) > EJB-QL for "IS EMPTY" on relation table uses wrong column and is broken in > general > ---------------------------------------------------------------------------------- > > Key: JBAS-1263 > URL: http://jira.jboss.com/jira/browse/JBAS-1263 > Project: JBoss Application Server > Type: Bug > Components: CMP service > Versions: JBossAS-4.0.1 Final, JBossAS-4.0.0 Final > Environment: JDK 1.5.0, Windows XP+SP2, MySQL, Connector/J 3.1.6 > Reporter: cgs > Assignee: Alexey Loubyansky > > > TemplateEJB: > * @ejb.finder > * signature="java.util.Collection findPublic()" > * query="SELECT DISTINCT OBJECT(o) > * FROM template o > * WHERE o.organizationList IS EMPTY" > /** > * @ejb.interface-method > * > * @ejb.relation > * name="Organization-Template" > * role-name="template-belongs-to-organization" > * > * @jboss.relation > * fk-constraint="true" > * fk-column="organization_id" > * related-pk-field="id" > * > * @jboss.relation-table > * table-name="template_to_organization" > */ > public abstract Set getOrganizationList(); > public abstract void setOrganizationList(Set organizationList); > OrganizationEJB: > /** > * @ejb.interface-method > * > * @ejb.relation > * name="Organization-Template" > * role-name="organization-has-templates" > * > * @jboss.relation > * fk-constraint="true" > * fk-column="template_id" > * related-pk-field="id" > * > * @jboss.relation-table > * table-name="template_to_organization" > */ > public abstract Set getTemplateList(); > public abstract void setTemplateList(Set templateList); > The SQL that is generated for the finder is: > SELECT DISTINCT > t0_o.id, t0_o.image, t0_o.image_thumbnail, t0_o.image_thumbnail_type, > t0_o.image_type, t0_o.name, t0_o.template, t0_o.time_created, > t0_o.time_updated, t0_o.uuid > FROM > template t0_o, > organization t2_o_organizationList, > template_to_organization t1_o_organizationList_RELATION_T > WHERE ( > t1_o_organizationList_RELATION_T.template_id IS NULL AND > t0_o.id=t1_o_organizationList_RELATION_T.template_id AND > t2_o_organizationList.id=t1_o_organizationList_RELATION_T.organization_id > ) > The first condition shouldn't be checking if ``template_id IS NULL'', but > ``organization_id IS NULL''. Even if it properly checked organization_id, > the query still would not work. If a relation using a relation table has an > empty list, the second condition is never matched. The list is always empty > and it cannot proceed. (t1_o_organizationList_RELATION_T.template_id will > never have any values in an empty relation.) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ JBoss-Development mailing list JBoss-Development@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-development