Re: context.objectsFromDataRows behaviour

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Feb 09 2005 - 10:00:25 EST

  • Next message: Steve Wells: "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 - 10:00:27 EST