Re: SQLTemplate with more than one class

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sun Feb 05 2006 - 16:12:35 EST

  • Next message: Ingo Feulner: "Re: Performance problem 1.2"

    You can simply include full sets of columns from both DbEntities
    (labeled the way they are labeled in DbEntities), or at the minimum,
    just the PK columns. Then do setFetchingDataRows(true) and obtain
    each object from the same row by calling DataContext.objectFromDataRow
    ().

    Also In 1.2 there is a hack that allows you to map a result row as a
    *tree* composed of a root class and one or more *prefetched* and
    *related* classes. This is undocumented as this was simply a side
    effect of joint prefetch feature, and I am yet unsure whether it is a
    good idea to keep it in the current state. But, FWIW ... The trick is to

    1. Make sure result labels are named according to the following
    naming convention: root class columns should use their DbEntity
    names; related class columns should use DbRelationship path, e.g.:
    TO_ARTIST.ARTIST_ID, TO_ARTIST.ARTIST_NAME. Custom labeling of result
    columns can be done with #result() directive (safe) or "column as
    xyz" SQL clause (less safe)

    2. Setup correct prefetches in SQLTemplate, e.g.
    sqlTemplate.addPrefetch("toArtist");

    Andrus

    On Feb 4, 2006, at 10:21 AM, Chronos wrote:
    > Hi!
    >
    > Is there a possibility to use SQLTemplate with more than one class? My
    > destination is to implement this SQL-Query:
    > "SELECT TabA.id,groupname,TabB.r,TabB.e,TabB.d FROM TabA,TabB WHERE
    > document_id=1 AND group_id=1 AND group_id<>1"
    >
    > Thanks for your help,
    >
    > PK
    >



    This archive was generated by hypermail 2.0.0 : Sun Feb 05 2006 - 16:12:41 EST