Re: retrive data from Multiple tables using SqlTemplate

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Mar 24 2005 - 10:32:54 EST

  • Next message: Orion Fields: "Re: deadlock between commit and external event"

    Sami,

    You can run arbitrary SQL via SQLTemplate. It'll work as long as it has a
    valid syntax for the target database.

    One thing to watch out is mapping the result back to objects. This is just
    common sense - if result can be mapped to one of the object entities in
    your Cayenne model, you can get DataOjects back. If not, you'll have to
    deal with results in the form of DataRows -
    http://www.objectstyle.org/cayenne/userguide/perform/data-rows.html.

    Andrus

    > Hi
    >
    > Can retrive data from multiple tables using SQLTemplate
    >
    > example
    > i have 3 tables TableA,Table B, TableC.
    > can i wirte SQLTemplate like this:
    > String sql ="select a. name, b.Des, c.dateField from TableA a,TableB b,
    > TableC c, where a.Pid = b.Pid" SQLTemplate query = new
    > SQLTemplate(TableA.class, sql);
    >
    > above statement is correct or not.
    >
    > Thanks
    > sami



    This archive was generated by hypermail 2.0.0 : Thu Mar 24 2005 - 10:32:55 EST