filtered prefetches

From: Cris Daniluk (cris.danilu..mail.com)
Date: Thu Apr 28 2005 - 13:53:50 EDT

  • Next message: Filip Balas: "Re: Hierarchical relationship problems"

    I'm currently using an expression to query for Users based on Roles
    (through a UserRole join table) as such:

    SelectQuery userSearchQuery = new SelectQuery(User.class,
    ExpressionFactory.matchExp("toUserRole.toRoleArray", searchRole));
    userSearchQuery.addPrefetch("toUserRole");

    The search works as expected, but the prefetch does not. Cayenne is
    applying the Expression from the base query to the prefetch:

    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.

    The prefetch should contain all roles for the matching users, not just
    the ones that were used in selecting the user. The behavior makes
    sense based on how prefetches were done, but this really seems like a
    bug to me...

    Cris



    This archive was generated by hypermail 2.0.0 : Thu Apr 28 2005 - 13:53:52 EDT