Re: Equivalent for WebObjects localInstanceOfObject() or Toplink registerExistingObject()?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Nov 14 2003 - 02:32:16 EST

  • Next message: Mike Kienenberger: "Re: Equivalent for WebObjects localInstanceOfObject() or Toplink registerExistingObject()?"

    FYI: this feature has just been checked in to both STABLE and HEAD as a
    new DataContext method "localObjects". There is a new documentation
    chapter in the user guide for it. It will be officially released as a
    part of 1.0.3 and onwards.

    Should allow custom implementations of what Shared Editing Context does
    for EOF. We may actually even implement a utility class in Cayenne that
    does caching based on SelectQuery used for read-only lookup queries.

    Andrus

    On Sep 9, 2003, at 2:22 PM, Mike Kienenberger wrote:
    >>> How can I use/copy an object that exists in one DataContext into
    >>> another
    >>> DataContext

    >> public static List getLocalObjects(DataContext context, List
    >> objects)
    > {
    >> List localList = new ArrayList(objects.size());
    >> Iterator it = objects.iterator();
    >> while (it.hasNext()) {
    >> DataObject obj = (DataObject) it.next();
    >> if (obj.getDataContext() != context) {
    >> ObjEntity ent =
    >> context.getEntityResolver().lookupObjEntity(
    >> obj.getObjectId().getObjClass());
    >> obj =
    >> context.objectFromDataRow(
    >> ent,
    >> obj.getCurrentSnapshot(),
    >> true);
    >> }
    >>
    >> localList.add(obj);
    >> }
    >> return localList;
    >> }



    This archive was generated by hypermail 2.0.0 : Fri Nov 14 2003 - 02:32:22 EST