Re: SelectQuery and table that is synonym

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Jul 07 2005 - 16:44:04 EDT

  • Next message: shaun: "Registering DataObjects"

    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 : Thu Jul 07 2005 - 16:44:06 EDT