Re: context.objectsFromDataRows behaviour

From: Steve Wells (stwell..wnmail.net)
Date: Wed Feb 09 2005 - 17:49:12 EST

  • Next message: Zvonimir Spajic: "how to store/save not PKs in the join-tables instead of storing the id's"

    Hi Andrus,

    Thanks for that. I did have an "id" field defined but of course it was
    null as it was never in the SP resultset. So I deleted that and set the
    PK to be one that is a real PK and it works fine.

    Thanks,

    Steve

    ----- Original message -----
    From: "Andrus Adamchik" <andru..bjectstyle.org>
    To: cayenne-use..bjectstyle.org
    Date: Wed, 9 Feb 2005 10:00:25 -0500 (EST)
    Subject: Re: context.objectsFromDataRows behaviour

    Hi Steve,

    The most common reason would be that DocInfo PK is not defined at all or
    does not describe a unique combination of columns to form a valid
    ObjectId. The difference between case 1 and 2 is probably a red
    herring...
    After you finish the iteration, all your object references will point to
    the same object (the last one)...

    Andrus

    > Hi all,
    >
    > Sadly I have to call stored procs to SQL server, am using jtds 1.0 and
    > Cayenne 1.2M2. So I created a DataObject and try to convert from rows
    > to objects.
    >
    > This works:
    > List rows = context.performQuery(query);
    > // process results
    > Iterator it = rows.iterator();
    > while (it.hasNext()) {
    > DataRow row = (DataRow) it.next();
    >
    > // do something with result, e.g. instantiate a real DataObject
    > DocInfo object = (DocInfo)
    > context.objectFromDataRow(DocInfo.class, row, true);
    > log.info(object);
    > }
    >
    > But this does NOT:
    > List list = context.objectsFromDataRows(DocInfo.class, rows, false,
    > false);
    > for (int i = 0; i < list.size(); i++) {
    > Object o = list.get(i);
    > log.info(o);
    > }
    >
    > What I get is always the first row repeated from the original resultset.
    > If the query returns 100 rows, I get the first result from that set in
    > the variable called "list", 100 times. Also if I set refresh param to
    > true I get the last result 100 times
    > (context.objectsFromDataRows(DocInfo.class, rows, true, false))
    >
    > Anyone else been using this sucessfully with SP's?
    >
    > Also which would be the recommended technique anyway?
    >
    > Thanks,
    >
    > Steve



    This archive was generated by hypermail 2.0.0 : Wed Feb 09 2005 - 17:49:13 EST