You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Hugi Thordarson <hu...@karlmenn.is> on 2016/03/04 11:34:15 UTC
How to check if an ObjectContext is the root ObjectContext? (has no parent)
Hi all.
How do I check if an ObjectContext is the root ObjectContext, i.e. does not have a parent ObjectContext? Do I simply check if the ObjectContext’s channel is an instance of an ObjectContext to see if it’s a child context?
Cheers,
- hugi
Re: How to check if an ObjectContext is the root ObjectContext? (has no parent)
Posted by Andrus Adamchik <an...@objectstyle.org>.
Yep, still true in 4.0
> On Mar 4, 2016, at 5:56 AM, Michael Gentry <mg...@masslight.net> wrote:
>
> Hi Hugi,
>
> I believe that's true, at least for 3.1. I had this lying around somewhere
> that seemed to work:
>
> public static boolean isChildContext(ObjectContext context)
> {
> if (context.getChannel() instanceof ObjectContext)
> return true;
> else
> return false;
> }
>
> mrg
>
>
>
> On Fri, Mar 4, 2016 at 5:34 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>
>> Hi all.
>> How do I check if an ObjectContext is the root ObjectContext, i.e. does
>> not have a parent ObjectContext? Do I simply check if the ObjectContext’s
>> channel is an instance of an ObjectContext to see if it’s a child context?
>>
>> Cheers,
>> - hugi
Re: How to check if an ObjectContext is the root ObjectContext? (has
no parent)
Posted by Michael Gentry <mg...@masslight.net>.
Hi Hugi,
I believe that's true, at least for 3.1. I had this lying around somewhere
that seemed to work:
public static boolean isChildContext(ObjectContext context)
{
if (context.getChannel() instanceof ObjectContext)
return true;
else
return false;
}
mrg
On Fri, Mar 4, 2016 at 5:34 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> Hi all.
> How do I check if an ObjectContext is the root ObjectContext, i.e. does
> not have a parent ObjectContext? Do I simply check if the ObjectContext’s
> channel is an instance of an ObjectContext to see if it’s a child context?
>
> Cheers,
> - hugi