You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Markus Reich <ma...@markusreich.at> on 2013/05/15 14:48:15 UTC
Prefetch paths
Hi,
is it possible to use wildcards in prefetch paths?
e.g. query.addPrefetch("paintings.gallery");
regards
Meex
Re: Prefetch paths
Posted by Markus Reich <ma...@markusreich.at>.
thank you for this great snippet :-)
2013/5/15 Daniel Abrams <da...@gmail.com>
> We do something similar to this. Here is a snippet that will prefetch all
> the relationships on a given entity. If you want to do this via compound
> keypaths, you would need to parse the keys and do this recursively, but
> that might be a little dangerous in terms of fetching lots of data.
>
> DataContext dataContext = (DataContext) object.getObjectContext();
> ObjEntity objEntity =
> dataContext.getEntityResolver().lookupObjEntity(object.getClass());
>
> for (Relationship relationship : objEntity.getRelationships())
> {
> query.addPrefetch(relationship.getName());
> }
>
>
>
>
> On Wed, May 15, 2013 at 9:42 AM, Andrus Adamchik <andrus@objectstyle.org
> >wrote:
>
> > Yeah, Mike is right. No way to use a wildcard. All paths should be
> > explicit.
> >
> > (Thinking whether it might be a good idea to add that in the future … )
> >
> > On May 15, 2013, at 4:36 PM, Markus Reich <ma...@markusreich.at>
> > wrote:
> > > oops, sorry, it should be like this
> > >
> > > query.addPrefetch("paintings.*");
> > >
> > >
> > > 2013/5/15 Michael Gentry <mg...@masslight.net>
> > >
> > >> Hi Markus,
> > >>
> > >> I don't see a wildcard there, but I don't think you can use wildcards
> on
> > >> prefetches. I think you have to specify each one.
> > >>
> > >> mrg
> > >>
> > >>
> > >> On Wed, May 15, 2013 at 8:48 AM, Markus Reich
> > >> <ma...@markusreich.at>wrote:
> > >>
> > >>> Hi,
> > >>>
> > >>> is it possible to use wildcards in prefetch paths?
> > >>>
> > >>> e.g. query.addPrefetch("paintings.gallery");
> > >>>
> > >>> regards
> > >>> Meex
> > >>>
> > >>
> > >
> > >
> > >
> > > --
> > > *Markus Reich*
> > > Moosbach 28/2
> > > 6392 St. Jakob i.H.
> > > www.markusreich.at / www.meeximum.at
> > > markus.reich@markusreich.at
> >
> >
>
--
*Markus Reich*
Moosbach 28/2
6392 St. Jakob i.H.
www.markusreich.at / www.meeximum.at
markus.reich@markusreich.at
Re: Prefetch paths
Posted by Daniel Abrams <da...@gmail.com>.
We do something similar to this. Here is a snippet that will prefetch all
the relationships on a given entity. If you want to do this via compound
keypaths, you would need to parse the keys and do this recursively, but
that might be a little dangerous in terms of fetching lots of data.
DataContext dataContext = (DataContext) object.getObjectContext();
ObjEntity objEntity =
dataContext.getEntityResolver().lookupObjEntity(object.getClass());
for (Relationship relationship : objEntity.getRelationships())
{
query.addPrefetch(relationship.getName());
}
On Wed, May 15, 2013 at 9:42 AM, Andrus Adamchik <an...@objectstyle.org>wrote:
> Yeah, Mike is right. No way to use a wildcard. All paths should be
> explicit.
>
> (Thinking whether it might be a good idea to add that in the future … )
>
> On May 15, 2013, at 4:36 PM, Markus Reich <ma...@markusreich.at>
> wrote:
> > oops, sorry, it should be like this
> >
> > query.addPrefetch("paintings.*");
> >
> >
> > 2013/5/15 Michael Gentry <mg...@masslight.net>
> >
> >> Hi Markus,
> >>
> >> I don't see a wildcard there, but I don't think you can use wildcards on
> >> prefetches. I think you have to specify each one.
> >>
> >> mrg
> >>
> >>
> >> On Wed, May 15, 2013 at 8:48 AM, Markus Reich
> >> <ma...@markusreich.at>wrote:
> >>
> >>> Hi,
> >>>
> >>> is it possible to use wildcards in prefetch paths?
> >>>
> >>> e.g. query.addPrefetch("paintings.gallery");
> >>>
> >>> regards
> >>> Meex
> >>>
> >>
> >
> >
> >
> > --
> > *Markus Reich*
> > Moosbach 28/2
> > 6392 St. Jakob i.H.
> > www.markusreich.at / www.meeximum.at
> > markus.reich@markusreich.at
>
>
Re: Prefetch paths
Posted by Michael Gentry <mg...@masslight.net>.
Personally, it seems like a bad idea to me. If you add a relationship or
two and it automatically started prefetching them all due to wildcards, I
could see performance tanking quickly. I'd rather explicitly state
prefetches when I know I want the data more immediately.
mrg
On Wed, May 15, 2013 at 9:42 AM, Andrus Adamchik <an...@objectstyle.org>wrote:
> Yeah, Mike is right. No way to use a wildcard. All paths should be
> explicit.
>
> (Thinking whether it might be a good idea to add that in the future … )
>
> On May 15, 2013, at 4:36 PM, Markus Reich <ma...@markusreich.at>
> wrote:
> > oops, sorry, it should be like this
> >
> > query.addPrefetch("paintings.*");
> >
> >
> > 2013/5/15 Michael Gentry <mg...@masslight.net>
> >
> >> Hi Markus,
> >>
> >> I don't see a wildcard there, but I don't think you can use wildcards on
> >> prefetches. I think you have to specify each one.
> >>
> >> mrg
> >>
> >>
> >> On Wed, May 15, 2013 at 8:48 AM, Markus Reich
> >> <ma...@markusreich.at>wrote:
> >>
> >>> Hi,
> >>>
> >>> is it possible to use wildcards in prefetch paths?
> >>>
> >>> e.g. query.addPrefetch("paintings.gallery");
> >>>
> >>> regards
> >>> Meex
> >>>
> >>
> >
> >
> >
> > --
> > *Markus Reich*
> > Moosbach 28/2
> > 6392 St. Jakob i.H.
> > www.markusreich.at / www.meeximum.at
> > markus.reich@markusreich.at
>
>
Re: Prefetch paths
Posted by Andrus Adamchik <an...@objectstyle.org>.
Yeah, Mike is right. No way to use a wildcard. All paths should be explicit.
(Thinking whether it might be a good idea to add that in the future … )
On May 15, 2013, at 4:36 PM, Markus Reich <ma...@markusreich.at> wrote:
> oops, sorry, it should be like this
>
> query.addPrefetch("paintings.*");
>
>
> 2013/5/15 Michael Gentry <mg...@masslight.net>
>
>> Hi Markus,
>>
>> I don't see a wildcard there, but I don't think you can use wildcards on
>> prefetches. I think you have to specify each one.
>>
>> mrg
>>
>>
>> On Wed, May 15, 2013 at 8:48 AM, Markus Reich
>> <ma...@markusreich.at>wrote:
>>
>>> Hi,
>>>
>>> is it possible to use wildcards in prefetch paths?
>>>
>>> e.g. query.addPrefetch("paintings.gallery");
>>>
>>> regards
>>> Meex
>>>
>>
>
>
>
> --
> *Markus Reich*
> Moosbach 28/2
> 6392 St. Jakob i.H.
> www.markusreich.at / www.meeximum.at
> markus.reich@markusreich.at
Re: Prefetch paths
Posted by Markus Reich <ma...@markusreich.at>.
oops, sorry, it should be like this
query.addPrefetch("paintings.*");
2013/5/15 Michael Gentry <mg...@masslight.net>
> Hi Markus,
>
> I don't see a wildcard there, but I don't think you can use wildcards on
> prefetches. I think you have to specify each one.
>
> mrg
>
>
> On Wed, May 15, 2013 at 8:48 AM, Markus Reich
> <ma...@markusreich.at>wrote:
>
> > Hi,
> >
> > is it possible to use wildcards in prefetch paths?
> >
> > e.g. query.addPrefetch("paintings.gallery");
> >
> > regards
> > Meex
> >
>
--
*Markus Reich*
Moosbach 28/2
6392 St. Jakob i.H.
www.markusreich.at / www.meeximum.at
markus.reich@markusreich.at
Re: Prefetch paths
Posted by Michael Gentry <mg...@masslight.net>.
Hi Markus,
I don't see a wildcard there, but I don't think you can use wildcards on
prefetches. I think you have to specify each one.
mrg
On Wed, May 15, 2013 at 8:48 AM, Markus Reich
<ma...@markusreich.at>wrote:
> Hi,
>
> is it possible to use wildcards in prefetch paths?
>
> e.g. query.addPrefetch("paintings.gallery");
>
> regards
> Meex
>