Re: Join Queries

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Oct 20 2005 - 16:50:50 EDT

  • Next message: Andrus Adamchik: "Re: Version 1.2 progress?"

    I am not sure if this is intentional omission or not, but the actual
    joining of related clients and regions is missing from your example.
    E.g. "A.RegionId = B.RegionId" (if client has an FK to region). If
    there is a PK/FK relationship between client and region, you can
    create an object query in the Modeler (or a SelectQuery in your
    code). Just use something like "db:ClientId = '123' and
    regions.regionName = 'XYZ'", assuming "regions" is the name of
    relationship.

    In other words, SelectQuery would work if you can express your WHERE
    clause conditions as one or more "path" property expressions
    originating in the query root object (note that other tables can be
    included in the condition, as long as there is a defined Cayenne
    relationship from the "root" table to those tables). If not -
    SQLTemplate is needed.

    Andrus

    On Oct 20, 2005, at 6:22 AM, Shah, Megha wrote:

    > Hi,
    >
    > I'am trying to execute a Join with parameters from both the tables
    > in the
    > join:
    >
    > Select A.ClientAddr, A.TelNo, B.RegionStatus from Client A, Region
    > B where
    > A.ClientId='123' and B.RegionName='XYZ'
    >
    > I have ObjEntities defined for Client and Region. Since the where
    > clause
    > contains conditions on both the tables, the SelectQuery (defined using
    > Modeler->Object Select Query) does not work.
    > Is it necessary to use SQLTemplate for the above or is some other
    > solution
    > possible?
    >
    > Thanks & Regards,
    > Megha Shah



    This archive was generated by hypermail 2.0.0 : Thu Oct 20 2005 - 16:50:52 EDT