-
Bug
-
Resolution: Won't Do
-
Major
-
JBossAS-4.0.0 Final, JBossAS-4.0.1 Final
-
None
-
JDK 1.5.0, Windows XP+SP2, MySQL, Connector/J 3.1.6
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.)