Simple query Expression question

From: Nenko Ivanov (nivano..cygen.com)
Date: Wed Aug 31 2005 - 10:50:42 EDT

  • Next message: Gentry, Michael \(Contractor\): "RE: ordering and path expression"

    Hi, as maybe you will understand from my question I'm a newbie in Cayenne.
    But last few hours I was struggling with building a simple table join
    expression, without any success.

    So the SQL looks like that

    SELECT col1... colN FROM table_name WHERE
    col = <some_value>
    AND col2 = col3

    I can not make the join between col2 and col3. This is a child-parrent
    relationship and in this significant
    case I have to fetch the root of this tree structure. (this query always
    returns one row)

    First join is done by this
      Expression expression = ExpressionFactory.matchDbExp(ClassName.PROPERTY,
            "<some_value>");
          SelectQuery sq = new SelectQuery(ClassName.class,
            expression);
    and what is the next step for the other join..

    sq.addPrefetch("<relationship_path>");

    builds query like this:

    SELECT col1... colN FROM table_name a,table_name b WHERE
    a.col = <some_value>
    AND a.col2 = b.col3

    because I have a relation between the required colums for joining.

    Thanks in advance for your help.

    PS. I was searching a lot for answer before bothering you with this stuff.



    This archive was generated by hypermail 2.0.0 : Wed Aug 31 2005 - 10:50:45 EDT