Re: setting a relationship from the wrong DataContext

From: Mike Kienenberger (mkienen..laska.net)
Date: Sat Apr 10 2004 - 17:54:38 EDT

  • Next message: Andrus Adamchik: "Re: VARCHAR2 and Oracle"

    Todd O'Bryan <toddobrya..ac.com> wrote:
    > When I grab a Category object, I get it from a special-purpose
    > DataContext which only exists while I'm getting the object.
    > But I want to use that Category in a Question that hasn't been
    > registered with a DataContext, yet. So, you can imagine
    > the problem:
    >
    > Cannot set object as destination of relationship category because it is
    > in a different DataContext
    >
    > How do I handle this elegantly?

    I put this in my DataObject superclass.

            public static DataObject getLocalObject(DataContext context, DataObject
    obj)
            {
                    if (null == obj) return null;
                    
                    if (obj.getDataContext() != context)
                    {
                            List localObjectList = context.localObjects(Arrays.asList(new Object[] {
    obj } ));
                            return (DataObject)localObjectList.get(0);
                    }
                    return obj;
            }



    This archive was generated by hypermail 2.0.0 : Sat Apr 10 2004 - 17:53:38 EDT