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

From: Mike Kienenberger (mkienen..laska.net)
Date: Fri Nov 14 2003 - 14:37:07 EST

  • Next message: Andrus Adamchik: "Cayenne Examples build changes"

    Andrus Adamchik <andru..bjectstyle.org> wrote:
    > 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.

    In practice, I've found I always use a simpler version that only retrieves a
    single object. Maybe it would make sense to add a "localObject" method as
    well.

            public static DataObject getLocalObject(DataContext context, DataObject
    obj)
            {
                    if (null == obj) return null;
                    
                    if (obj.getDataContext() != context)
                    {
                            ObjEntity ent =
    context.getEntityResolver().lookupObjEntity(obj.getObjectId().getObjClass());
                            obj = context.objectFromDataRow(ent, obj.getCurrentSnapshot(), true);
                    }
                    return obj;
            }



    This archive was generated by hypermail 2.0.0 : Fri Nov 14 2003 - 14:36:58 EST