Re: DataRow.createObjectId deprecated without mention of alternative...

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Jan 25 2008 - 07:59:45 EST

  • Next message: Andrus Adamchik: "Re: Problems running Cayenne ORM Tier and CWS Client Tier on the same JVM."

    On Jan 24, 2008, at 6:57 AM, Lachlan Deck wrote:

    > On 23/01/2008, at 9:12 PM, Andrus Adamchik wrote:
    >
    >> No replacement API in Cayenne. This was not deemed a useful user-
    >> level functionality,
    >
    > It was useful to me ;-)
    >
    > e.g.,
    > ObjectId rowId = dataRow.createObjectId(anObjEntity);
    > Map ids = rowId.getIdSnapshot();
    >
    > If I'm traversing the entire database (for example to determine what
    > records to queue for later processing by another thread) the above
    > means I don't need to fault in the real object to obtain the primary
    > key values.

    You can write a very simple utility method, e.g.:

    DbEntity entity = ...
    Map<String, Object> pk = new HashMap<String, Object>();
    for (DbAttribute attribute : entity.getPrimaryKeys()) {
        pk.put(attribute.getName(), row.get(attribute.getName());
    }

    >> and Cayenne itself uses a private method elsewhere to create
    >> ObjectId's, hence the deprecation.
    >
    > Okay, so when dealing with raw rows, what's the recommended route?
    >
    > Also is there an equivalent for
    > EOEntity.qualifierForPrimaryKey(NSDictionary) in order to build up
    > an or'd expression (as opposed to individually calling
    > DataObjectUtils.objectForPK(ObjectContext, String, Map) ?

    ExpressionFactory.matchAllDbExp(..)

    Andrus



    This archive was generated by hypermail 2.0.0 : Fri Jan 25 2008 - 08:00:20 EST