Re: Join Queries

From: Shah, Megha (Megha_Sha..yntelinc.com)
Date: Fri Oct 21 2005 - 00:42:16 EDT

  • Next message: Gentry, Michael \(Contractor\): "RE: Searching for Examples of Cayenne + HiveMind"

    Hi,

    Thanks for the help. I had already defined the relationship betn the 2
    tables in the DB itself.
    The problem was from my part of teh code and i was not sure how cayenne was
    retrieiving join values.

    Thanks again,
    Megha

    -----Original Message-----
    From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    Sent: Friday, October 21, 2005 2:21 AM
    To: cayenne-use..bjectstyle.org
    Subject: [SPAM] - Re: Join Queries - Bayesian Filter detected spam

    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

    Confidential: This electronic message and all contents contain information from Syntel, Inc. which may be privileged, confidential or otherwise protected from disclosure. The information is intended to be for the addressee only. If you are not the addressee, any disclosure, copy, distribution or use of the contents of this message is prohibited. If you have recieved this electronic message in error, please notify the sender immediately and destroy the original message and all copies.



    This archive was generated by hypermail 2.0.0 : Fri Oct 21 2005 - 00:43:09 EDT