DataObjectUtils.objectForPK, ObjectStore and DataRowStore

From: Tore Halset (halse..vv.ntnu.no)
Date: Thu Sep 23 2004 - 02:39:24 EDT

  • Next message: Andrus Adamchik: "Re: DataObjectUtils.objectForPK, ObjectStore and DataRowStore"

    Hello.

    I am using DataObjectUtils.objectForPK(...) in a newly created
    DataContext to fetch objects. The objects haa already been fetched in
    another DataContext. I hoped that this would not result in a fetch from
    the database, but a fetch from the cache. I have checked the "Use
    Shared Cache" checkbox in the modeler.

    The following code results in two queries. The cell with id "XX222222"
    are found in the first query as well. If I do not create the second
    DataContext the code only executes a single query.

             DataContext ctxt = DataContext.createDataContext();

             // query for all cells
             SelectQuery query = new SelectQuery(Cell.class);
             ctxt.performQuery(query);

             // create a new context
             ctxt = DataContext.createDataContext();

             // find a single cell
             Cell c = (Cell)DataObjectUtils.objectForPK(ctxt, Cell.class,
    "XX222222");
             log("found cell " + c.getCellId());

    Am I missing something? Are objectForPK only looking in the ObjectStore
    for cached objects? Or are my cell not in the DataRowStore?

    All of this is with 1.1B2 and 1.1B3.

    Regards,
      - Tore.



    This archive was generated by hypermail 2.0.0 : Thu Sep 23 2004 - 02:40:51 EDT