Re: SelectQuery and table that is synonym

From: laila paganelli (laila.paganell..mail.com)
Date: Fri Jul 08 2005 - 11:27:45 EDT

  • Next message: McDaniel, Joe R.: "RE: SelectQuery and table that is synonym"

    I have inserted tests with #result() directive, but the result doesn't change.
    The first query returns always wrong results.

    TEST 3 -------------------
    query = new SQLTemplate(RawNewsLanguage.class, "SELECT
    #result('t0.NOME' 'java.lang.String' 'NOME'), #result('t0.ID_LNG'
    'java.lang.Integer' 'ID') FROM RAWNWSLNG_LAILA t0 WHERE t0.NOME =
    'english'", true);

    Output:
    INFO QueryLogger: SELECT t0.NOME AS NOME, t0.ID_LNG AS ID FROM
    RAWNWSLNG_LAILA t0 WHERE t0.NOME = 'english'
    INFO QueryLogger: === returned 1 row. - took 493 ms.
    INFO QueryLogger: +++ transaction committed.
    org.objectstyle.cayenne.DataRo..30589[version=-9223372036854775806,
    replaces=-9223372036854775808, values={NOME=ç, ID=0}]

    TEST 4 --------------------
    query = new SQLTemplate(RawNewsLanguage.class, "SELECT
    #result('t0.ID_LNG' 'java.lang.Integer' 'ID'), #result('t0.NOME'
    'java.lang.String' 'NOME') FROM RAWNWSLNG_LAILA t0 WHERE t0.NOME =
    'english'", true);

    Output:

    INFO QueryLogger: SELECT t0.ID_LNG AS ID, t0.NOME AS NOME FROM
    RAWNWSLNG_LAILA t0 WHERE t0.NOME = 'english'
    INFO QueryLogger: === returned 1 row. - took 148 ms.
    INFO QueryLogger: +++ transaction committed.
    org.objectstyle.cayenne.DataRo..fdf86[version=-9223372036854775804,
    replaces=-9223372036854775808, values={NOME=english, ID=20}]

    I have try to use Eclipse debugger, but i don't understand which
    variable of the ResultSet contains the values searched.

    Laila

    ---------- Forwarded message ----------
    From: Andrus Adamchik <andru..bjectstyle.org>
    Date: Jul 7, 2005 10:44 PM
    Subject: Re: SelectQuery and table that is synonym
    To: cayenne-use..bjectstyle.org

    Looks like your are onto something here, though I still can't tell
    what the problem is. What happens if you use #result() directive with
    SQLTemplate (http://objectstyle.org/cayenne/userguide/fetch/
    sqltemplate-scripting.html) ? My guess is that this shouldn't make
    much difference (as SelectQuery does the right thing in this
    respect), but still worth a try.

    One last thing you can do is to run the first test in (Eclipse)
    debugger and check what Oracle driver is returning in the ResultSet.

    Andrus

    On Jul 7, 2005, at 8:59 PM, laila paganelli wrote:

    > Andrus,
    >
    > I have create some test and I have discovered this strange result
    >
    >
    > TEST 1
    > ----------------------------
    > query = new SQLTemplate(RawNewsLanguage.class, "SELECT t0.NOME,
    > t0.ID_LNG FROM RAWNWSLNG_LAILA t0 WHERE t0.NOME = 'english'", true);
    > query.setFetchingDataRows(true);
    >
    > Returns a wrong result like this
    >
    > org.objectstyle.cayenne.DataRo..6484c[version=-9223372036854775807,
    > replaces=-9223372036854775808,
    > values=
    > {ID_LNG=-0.00000000000000000000000000000000000000000000000000000000000
    > 000000000000281474074640242,
    > NOME=ç}]
    >
    >
    > TEST 2
    > ------------------------------
    > query = new SQLTemplate(RawNewsLanguage.class, "SELECT t0.ID_LNG,
    > t0.NOME FROM RAWNWSLNG_LAILA t0 WHERE t0.NOME = 'english'", true);
    > query.setFetchingDataRows(true);
    >
    > Returns a right result like this
    > org.objectstyle.cayenne.DataRo..306ad[version=-9223372036854775806,
    > replaces=-9223372036854775808, values={ID_LNG=20, NOME=english}]
    >
    >
    > The only difference between queries above is the order of selected
    > columns.
    > When I try to read a RawNewLanguage object with
    > new SelectQuery(RawNewsLanguage.class, Expression.fromString("nome
    > = 'english'"));
    > cayenne generate the first query and gets wrong result.
    >
    > What do you think?
    >
    >
    > Laila
    >
    >
    >
    > On 7/7/05, Andrus Adamchik <andru..bjectstyle.org> wrote:
    >
    >
    >> Laila,
    >>
    >> I am replying via cayenne-user - this discussion is a better fit for
    >> the user list.
    >>
    >> I really can't think of a reason for such behavior, so how about
    >> trying a few things to debug the JDBC layer. Start by turning on data
    >> rows fetch and check for differences in values (and keys!) in the
    >> returned data row maps:
    >>
    >> query.setFetchingDataRows(true);
    >>
    >> This may give some hints...
    >>
    >> Andrus
    >>
    >>
    >> On Jul 6, 2005, at 2:28 PM, laila paganelli wrote:
    >>
    >>
    >>
    >>> Hi,
    >>>
    >>> I'm trying to run a SelectQuery on a table that is a synonym of a
    >>> remote table.
    >>> I'm using oracle 10.1.0.4 and cayenne 1.2M4 jars.
    >>>
    >>> dataContext = DataContext.createDataContext(false);
    >>> expression = Expression.fromString("name = 'english'");
    >>> query = new SelectQuery(RawNewsLanguage.class, expression);
    >>> result = (RawNewsLanguage)dataContext.performQuery(query).get(0);
    >>>
    >>> The cayenne query is SELECT t0.NAME, t0.ID_LNG FROM RAWNWSLNG t0
    >>> WHERE
    >>> t0.NAME = ? [bind: 'english']
    >>>
    >>> If I run this query on a database with original RAWNWSLNG table, the
    >>> result is correct
    >>>
    >>> {[ name => english
    >>> ]<oid: com.extrapola.scooter.dataModel.RawNewsLanguage: <ID_LNG:
    >>> 20>; state: committed>}
    >>>
    >>>
    >>> But if I run the query on a database with RAWNWSLNG like synonym, I
    >>> have a strange result
    >>>
    >>> {[ name => ç
    >>> ]<oid: com.extrapola.scooter.dataModel.RawNewsLanguage:
    >>> <ID_LNG: 0>;
    >>> state: committed>}
    >>>
    >>> Where is the problem?
    >>> How I can run my application on tables that are synonyms?
    >>>
    >>> Thanks,
    >>> Laila
    >>>
    >>>
    >>>
    >>>
    >>
    >>
    >>
    >>
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Fri Jul 08 2005 - 11:28:09 EDT