Mike,
Elsewhere in the list I saw Andrus call context.localObjects and use
this as a parameter:
Collections.singletonList(obj)
As opposed to your
Arrays.asList(new Object[] { obj } )
Both seem to convert a single item to a list. Is there any difference?
// Craig Jones (experienced OOP'er, but fairly new to
Java/Cayenne/Tapestry)
-----Original Message-----
From: Mike Kienenberger [mailto:mkienen..laska.net]
Sent: Saturday, April 10, 2004 2:55 PM
To: Todd O'Bryan
Cc: cayenne-use..bjectstyle.org
Subject: Re: setting a relationship from the wrong DataContext
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 - 18:38:08 EDT