Re: Problem traversing relationships - need hint

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Jun 20 2006 - 02:25:45 EDT

  • Next message: Fredrik Liden: "Deployment advice"

    The query certainly looks fishy. I suspect this may be related to
    this issue:

       http://issues.apache.org/cayenne/browse/CAY-447

    Now the question is whether your relationship problem is also related
    to that. I guess it would help if you post your DataMap XML subset
    containing the 4 entities in question.

    Andrus

    On Jun 19, 2006, at 8:32 PM, Arturo Perez wrote:

    > Andrus Adamchik <andrus <at> objectstyle.org> writes:
    >
    >>
    >>
    >> On Jun 19, 2006, at 5:13 PM, Arturo Perez wrote:
    >>
    >>> Iterator i = articleCategory.getArticles().iterator();
    >>> while (i.hasNext()) {
    >>> ArticleCategoryLink acl = (ArticleCategoryLink)i.next();
    >>> ArticleMeta am = acl.getLatestArticle();
    >>> Article a = am.getArticle();
    >>> }
    >>>
    >>> The article is null but if I run an Expression I get what I expect:
    >>>
    >>> Expression exp =
    >>> ExpressionFactory.matchExp("activeArticle.categories.category",
    >>> category);
    >>> exp = exp.andExp(
    >>> Expression.fromString("latestArticle.article
    >>> activeArticle.article"));
    >>
    >> The last expression looks strange (I am surprised it compiles). What
    >> SQL is generated for the query?
    >>
    >> Andrus
    >>
    >>
    >
    > It looks like the equal sign went away. It should be
    > "latestArticle.article = activeArticle.article"
    >
    > That last expression is intended to limit results to the current
    > articles.
    > Everything has backissues that should be ignored for the above.
    > The SQL
    > is a 4-way join:
    >
    >
    > 2006-06-19 12:25:21,249 [http-8316-Processor24] WARN
    > org.objectstyle.cayenne.access.QueryLogger- SELECT DISTINCT
    > t0.ARTICLE_ID,
    > t0.ARTICLE_META_ID FROM ARTICLE t0, ARTICLE_META t1,
    > ARTICLE_CATEGORY_LINK t2, ARTICLE_META t3 WHERE t0.ARTICLE_ID =
    > t1.ACTIVE_ARTICLE_ID AND t1.ARTICLE_META_ID = t2.ARTICLE_META_ID AND
    > t0.ARTICLE_META_ID = t3.ARTICLE_META_ID AND ((t2.CATEGORY_ID = ?) AND
    > (t1.ACTIVE_ARTICLE_ID = t1.ACTIVE_ARTICLE_ID)) [bind: 1042]
    > 2006-06-19 12:25:23,608 [http-8316-Processor24] WARN
    > org.objectstyle.cayenne.access.QueryLogger- === returned 91 rows.
    > - took
    > 2359 ms.
    >
    >
    >
    > I suppose I should change the above to a matchInExp to cut down on
    > the join
    > but I'm more concerned about the null. Although, looking at that
    > SQL, the
    > last AND clause seems incorrect.
    >
    > -arturo



    This archive was generated by hypermail 2.0.0 : Tue Jun 20 2006 - 02:26:10 EDT