Message:
A new issue has been created in JIRA.
---------------------------------------------------------------------
View the issue:
http://objectstyle.org/jira/secure/ViewIssue.jspa?key=CAY-319
Here is an overview of the issue:
---------------------------------------------------------------------
Key: CAY-319
Summary: Filtered Prefetches
Type: Bug
Status: Assigned
Priority: Critical
Project: Cayenne
Components:
Cayenne Core Library
Versions:
1.1
Assignee: Andrus Adamchik
Reporter: Cris Daniluk
Created: Tue, 24 May 2005 11:50 AM
Updated: Tue, 24 May 2005 11:50 AM
Description:
Given an expression graph and a prefetch graph, the prefetched query will be filtered by any intersecting nodes. As an example, the following query:
SelectQuery userSearchQuery = new SelectQuery(User.class,
ExpressionFactory.matchExp("toUserRole.toRoleArray", searchRole));
userSearchQuery.addPrefetch("toUserRole");
will produce an incomplete "toUserRole" relationship, filtering out all but the roles that were searched for. The SQL generated by such a query is provided below:
SELECT DISTINCT t0.TX_FIRST_NAME, t0.TX_LAST_NAME, t0.TX_LOGIN_NAME,
t0.NU_USER_ID FROM USER t0, USER_ROLE t1 WHERE t0.NU_USER_ID =
t1.NU_USER_ID AND ((t1.NU_ROLE_ID = ?) AND (UPPER(t0.TX_LOGIN_NAME)
LIKE UPPER(?))) [bind: 0, 'cris']
=== returned 1 row. - took 141 ms.
SELECT t0.NU_ROLE_ID, t0.NU_USER_ID FROM USER_ROLE t0, USER t1 WHERE
t0.NU_USER_ID = t1.NU_USER_ID AND ((t0.NU_ROLE_ID = ?) AND
(UPPER(t1.TX_LOGIN_NAME) LIKE UPPER(?))) [bind: 0, 'cris']
=== returned 1 row. - took 93 ms.
As noted, the second query binds the role. Given 2 graphs with non-empty intersections, it is not possible to do this query without a subselect. The following approaches could resolve this issue:
1. The prefetch could be removed (with a WARN log event)
2. The relationship could be left as a fault, with the objects that
were prefetched pre-resolved
3. A subselect (or select ... in) could be used on supported database adapters.
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://objectstyle.org/jira/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
This archive was generated by hypermail 2.0.0 : Tue May 24 2005 - 11:51:19 EDT