You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Lon Varscsak <lo...@gmail.com> on 2018/08/15 23:25:37 UTC
Finding an object in an ObjectContext
I have a situation where I need to query the inserted objects in an
ObjectContext to see if there's one already created. I know this is an odd
situation, but is there a way to accomplish this or should I just parse
through newObjects()?
Thanks,
Lon
Re: Finding an object in an ObjectContext
Posted by Lon Varscsak <lo...@gmail.com>.
Okay, thanks!
On Thu, Aug 16, 2018 at 2:24 AM Jurgen <do...@xsinet.co.za> wrote:
> I think you can kinda "query" the inserted objects using an Expression, eg:
>
> Expression filter = ExpressionFactory.likeExp( FooClass.FOO_PROPERTY,
> "\\Q"+ text +"\\E" );
> FooClass match = filter.<FooClass>first( (List<FooClass>)
> getObjectContext().newObjects() );
> if ( match != null ) .....
>
> Jurgen
>
> -----Original Message-----
> From: Andrus Adamchik
> Sent: Thursday, August 16, 2018 9:38 AM
> To: user@cayenne.apache.org
> Subject: Re: Finding an object in an ObjectContext
>
> > or should I just parse through newObjects()?
>
> Yes.
>
> Andrus
>
> > On Aug 16, 2018, at 2:25 AM, Lon Varscsak <lo...@gmail.com>
> wrote:
> >
> > I have a situation where I need to query the inserted objects in an
> > ObjectContext to see if there's one already created. I know this is an
> > odd
> > situation, but is there a way to accomplish this or should I just parse
> > through newObjects()?
> >
> > Thanks,
> >
> > Lon
>
>
Re: Finding an object in an ObjectContext
Posted by Jurgen <do...@xsinet.co.za>.
I think you can kinda "query" the inserted objects using an Expression, eg:
Expression filter = ExpressionFactory.likeExp( FooClass.FOO_PROPERTY,
"\\Q"+ text +"\\E" );
FooClass match = filter.<FooClass>first( (List<FooClass>)
getObjectContext().newObjects() );
if ( match != null ) .....
Jurgen
-----Original Message-----
From: Andrus Adamchik
Sent: Thursday, August 16, 2018 9:38 AM
To: user@cayenne.apache.org
Subject: Re: Finding an object in an ObjectContext
> or should I just parse through newObjects()?
Yes.
Andrus
> On Aug 16, 2018, at 2:25 AM, Lon Varscsak <lo...@gmail.com> wrote:
>
> I have a situation where I need to query the inserted objects in an
> ObjectContext to see if there's one already created. I know this is an
> odd
> situation, but is there a way to accomplish this or should I just parse
> through newObjects()?
>
> Thanks,
>
> Lon
Re: Finding an object in an ObjectContext
Posted by Andrus Adamchik <an...@objectstyle.org>.
> or should I just parse through newObjects()?
Yes.
Andrus
> On Aug 16, 2018, at 2:25 AM, Lon Varscsak <lo...@gmail.com> wrote:
>
> I have a situation where I need to query the inserted objects in an
> ObjectContext to see if there's one already created. I know this is an odd
> situation, but is there a way to accomplish this or should I just parse
> through newObjects()?
>
> Thanks,
>
> Lon