Re: SQLTemplate doing something differently?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon May 24 2004 - 12:33:57 EDT

  • Next message: Eric Schneider: "Re: SQLTemplate doing something differently?"

    Hi Eric,

    > org.objectstyle.cayenne.CayenneRuntimeException
    > [v.1.1M6 April 25 2004] Null value for 'GAMENUMBER'. Snapshot:
    > org.objectstyle.cayenne.DataRo..7b35d[version=
    > -9223372036854775130,values={
    > PERIOD3GOALS=9, OVERTIMEGOALS=1, PERIOD1GOALS=10, PERIOD2GOALS=9}]
    > Stack Trace:
    > org.objectstyle.cayenne.DataRow.createObjectId(DataRow.java:198)
    > org.objectstyle.cayenne.DataRow.createObjectId(DataRow.java:173)

    There are two related differences between SqlSelectQuery and
    SQLTemplate:

    1. SqlSelectQuery always fetches data rows; SQLTemplate fetches
    DataObjects by default and can be configured to fetch DataRows by
    calling "setFetchingDataRows(true)".

    2. "Root" of SqlSelectQuery was used to find correct DataNode, and
    otherwise was meaningless; root of SQLTemplate defines a class of
    objects, just like in a normal SelectQuery (unless you fetch data rows
    of course).

    > Select p1g.PERIOD1GOALS, p2g.PERIOD2GOALS, p3g.PERIOD3GOALS,
    > otg.OVERTIMEGOALS

    So whatever class you used as a query root has GAMENUMBER as one of
    the PK columns. Since this column is missing from the result set,
    Cayenne throws an exception. If you don't care about having an object
    and can use a data row, just call "setFetchingDataRows(true)" on the
    query, otherwise add all missing columns to the "SELECT ..." part of
    your SQLTemplate.

    Andrus



    This archive was generated by hypermail 2.0.0 : Mon May 24 2004 - 12:34:05 EDT