FAQ
This is perfect, thank you :). Couple of additional questions though:

1) When fetching data rows, can I limit the set of fields fetched, i.e. is there an equivalent to EOF’s EOFetchSpecification.setRawRowKeyPaths( NSArray )?

2) When specifying the prefetch, why do I have to addPrefetch( A.SOME_REL.joint() ) instead of just doing addPrefetch( “someRel” )? When traversing further relationships, is this the correct way? :

q.addPrefetch( PrefetchTreeNode.withPath( "shop.chain", 1 ) );

Cheers,
- hugi

// Hugi Thordarson
// http://www.loftfar.is/ <http://www.loftfar.is/>
// s. 895-6688


On 31. okt. 2014, at 10:34, Andrus Adamchik wrote:

If I understand the task correctly, a combination of JOINT prefetching and "data rows" should probably do the trick:

SelectQuery<A> query = new SelectQuery<>(A.class);
query.addPrefetch(A.SOME_REL.joint());
query.setFetchingDataRows(true);

Andrus
On Oct 31, 2014, at 1:14 PM, Hugi Thordarson wrote:

Hi all.

Once again, I’m looking into migrating to Cayenne from EOF :). One question though: Our code depends heavily on raw row fetching (data rows) that traverses relationships. I haven’t looked much at the Cayenne code, but do you believe adding support for this to Cayenne would be a huge undertaking? Or does Cayenne perhaps provide an alternative method to achieve the same results?

Cheers,
- hugi

PS: My apologies for the previous post, which my brain for some reason decided to post as an answer to an older thread. I’m still on my first cup of coffee, and it’s a really Monday-ish Friday up here.

// Hugi Thordarson
// http://www.loftfar.is/ <http://www.loftfar.is/>
// s. 895-6688

Search Discussions

  • Andrus Adamchik at Apr 1, 2015 at 10:52 am

    1) When fetching data rows, can I limit the set of fields fetched, i.e. is there an equivalent to EOF’s EOFetchSpecification.setRawRowKeyPaths( NSArray )?
    Not right now. This is doable with EJBQLQuery (it allows to specify individual columns, aggregate functions, etc). This functionality is coming soon to SelectQuery/ObjectSelect (probably in M3).
    2) When specifying the prefetch, why do I have to addPrefetch( A.SOME_REL.joint() ) instead of just doing addPrefetch( “someRel” )?
    You can still use the String. A.SOME_REL form is an alternative that gives you a compile-time guarantee that your property name is valid .
    When traversing further relationships, is this the correct way? :

    q.addPrefetch( PrefetchTreeNode.withPath( "shop.chain", 1 ) );
    q.addPrefetch( A.SHOP.dot(Shop.CHAIN).disjoint()) is probably a cleaner way.

    Andrus

    On Apr 1, 2015, at 1:38 PM, Hugi Thordarson wrote:

    This is perfect, thank you :). Couple of additional questions though:

    1) When fetching data rows, can I limit the set of fields fetched, i.e. is there an equivalent to EOF’s EOFetchSpecification.setRawRowKeyPaths( NSArray )?

    2) When specifying the prefetch, why do I have to addPrefetch( A.SOME_REL.joint() ) instead of just doing addPrefetch( “someRel” )? When traversing further relationships, is this the correct way? :

    q.addPrefetch( PrefetchTreeNode.withPath( "shop.chain", 1 ) );

    Cheers,
    - hugi

    // Hugi Thordarson
    // http://www.loftfar.is/ <http://www.loftfar.is/>
    // s. 895-6688


    On 31. okt. 2014, at 10:34, Andrus Adamchik wrote:

    If I understand the task correctly, a combination of JOINT prefetching and "data rows" should probably do the trick:

    SelectQuery<A> query = new SelectQuery<>(A.class);
    query.addPrefetch(A.SOME_REL.joint());
    query.setFetchingDataRows(true);

    Andrus
    On Oct 31, 2014, at 1:14 PM, Hugi Thordarson wrote:

    Hi all.

    Once again, I’m looking into migrating to Cayenne from EOF :). One question though: Our code depends heavily on raw row fetching (data rows) that traverses relationships. I haven’t looked much at the Cayenne code, but do you believe adding support for this to Cayenne would be a huge undertaking? Or does Cayenne perhaps provide an alternative method to achieve the same results?

    Cheers,
    - hugi

    PS: My apologies for the previous post, which my brain for some reason decided to post as an answer to an older thread. I’m still on my first cup of coffee, and it’s a really Monday-ish Friday up here.

    // Hugi Thordarson
    // http://www.loftfar.is/ <http://www.loftfar.is/>
    // s. 895-6688
  • Hugi Thordarson at Apr 1, 2015 at 12:02 pm

    1) When fetching data rows, can I limit the set of fields fetched, i.e. is there an equivalent to EOF’s EOFetchSpecification.setRawRowKeyPaths( NSArray )?
    Not right now. This is doable with EJBQLQuery (it allows to specify individual columns, aggregate functions, etc). This functionality is coming soon to SelectQuery/ObjectSelect (probably in M3).
    Great! We use EOF a lot for reporting so this will be really helpful performance/memory wise.
    2) When specifying the prefetch, why do I have to addPrefetch( A.SOME_REL.joint() ) instead of just doing addPrefetch( “someRel” )?
    You can still use the String. A.SOME_REL form is an alternative that gives you a compile-time guarantee that your property name is valid .
    Hmm, doesn’t seem to work. This code performs the expected prefetch:

      SelectQuery<DataRow> q = SelectQuery.dataRowQuery( SMReceipt.class );
      q.addPrefetch( SMReceipt.SHOP.joint() );
      List<DataRow> list = objectContext.select( q );

    While this doesn’t:

      SelectQuery<DataRow> q = SelectQuery.dataRowQuery( SMReceipt.class );
      q.addPrefetch( SMReceipt.SHOP.getName() );
      List<DataRow> list = objectContext.select( q );

    Should I file a bug report?

    When traversing further relationships, is this the correct way? :

    q.addPrefetch( PrefetchTreeNode.withPath( "shop.chain", 1 ) );
    q.addPrefetch( A.SHOP.dot(Shop.CHAIN).disjoint()) is probably a cleaner way.
    Thanks,
    - hugi
  • Andrus Adamchik at Apr 1, 2015 at 12:19 pm

    On Apr 1, 2015, at 2:59 PM, Hugi Thordarson wrote:

    While this doesn’t:

    SelectQuery<DataRow> q = SelectQuery.dataRowQuery( SMReceipt.class );
    q.addPrefetch( SMReceipt.SHOP.getName() );
    List<DataRow> list = objectContext.select( q );

    Should I file a bug report?
    Very surprising. This should generate a "disjoint" prefetch (i.e. a query #2, fetching Shop objects). And I am certain that we have dozens of unit tests for it. But yeah, if it is broken, please open a Jira, including generated SQL if possible.

    BTW, feel free to use ObjectSelect query, which a "fluent" analog of SelectQuery in M2.

    Andrus
  • Hugi Thordarson at Apr 1, 2015 at 1:50 pm

    While this doesn’t:

    SelectQuery<DataRow> q = SelectQuery.dataRowQuery( SMReceipt.class );
    q.addPrefetch( SMReceipt.SHOP.getName() );
    List<DataRow> list = objectContext.select( q );

    Should I file a bug report?
    Very surprising. This should generate a "disjoint" prefetch (i.e. a query #2, fetching Shop objects). And I am certain that we have dozens of unit tests for it. But yeah, if it is broken, please open a Jira, including generated SQL if possible.
    I was ablet o reproduce this in a different relationship so I filed an issue: https://issues.apache.org/jira/browse/CAY-1996 <https://issues.apache.org/jira/browse/CAY-1996> .

    BTW, feel free to use ObjectSelect query, which a "fluent" analog of SelectQuery in M2.
    Ah, very nice!

    - hugi

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedApr 1, '15 at 10:41a
activeApr 1, '15 at 1:50p
posts5
users2
websitecayenne.apache.org

People

Translate

site design / logo © 2021 Grokbase