You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Savva Kolbachev (JIRA)" <ji...@apache.org> on 2015/04/02 15:29:37 UTC

[jira] [Commented] (CAY-1996) Adding a prefetch to a SelectQuery via string path doesn't work

    [ https://issues.apache.org/jira/browse/CAY-1996?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14392576#comment-14392576 ] 

Savva Kolbachev commented on CAY-1996:
--------------------------------------

Hi Hugi! Thank you for your report.
I've investigated your problem and have found that it is not a bug.

The problem is SelectQuery uses DISJOINT_PREFETCH_SEMANTICS by default. But If a query is fetching DataRows, all "disjoint" prefetches are ignored, only "joint" prefetches are executed.

More information about Prefetching and Prefetching Semantics you can find here:
[https://cayenne.apache.org/docs/4.0/cayenne-guide/performance-tuning.html#prefetching]

So in your second use-case (FETCH 2), you can use:

{code}q.addPrefetch(SMReceipt.SHOP.getName()).setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);{code}

It works as well as your first use-case (FETCH 1).

> Adding a prefetch to a SelectQuery via string path doesn't work
> ---------------------------------------------------------------
>
>                 Key: CAY-1996
>                 URL: https://issues.apache.org/jira/browse/CAY-1996
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 4.0.M2
>         Environment: MySQL 5.5.40-MariaDB-36.1, InnoDB, Mac OS X 10.10, Java 8u40 (build 1.8.0_40-b27)
>            Reporter: Hugi Thordarson
>            Assignee: Savva Kolbachev
>
> Adding a prefetch to a selectQuery via the relationship's name only doesn't seem to work.
> Entity "SMReceipt" has a to-one relationship "shop" to the entity "SMShop". The first fetch performs a prefetch as expceted, the second fetch performs no prefetching.
> ----------------------------------
> FETCH 1 (working)
> ----------------------------------
> SelectQuery<DataRow> q = SelectQuery.dataRowQuery( SMReceipt.class );
> q.addPrefetch( SMReceipt.SHOP.joint() );
> List<DataRow> list = objectContext.select( q );
> ----------------------------------
> GENERATED SQL
> ----------------------------------
> SELECT t0.creation_date, t0.date, t0.modification_date, t0.shop_id, t0.storage_number, t0.text, t0.user_id, t0.id, t1.CITY_ID, t1.LOCATION, t1.NAME, t1.CHAIN_ID, t1.SHOP_ID FROM strimillinn.fd_receipt t0 LEFT JOIN strimillinn.fd_shop t1 ON (t0.shop_id = t1.SHOP_ID)
> ----------------------------------
> FETCH 2 (not working)
> ----------------------------------
> SelectQuery<DataRow> q = SelectQuery.dataRowQuery( SMReceipt.class );
> q.addPrefetch( SMReceipt.SHOP.getName() );
> List<DataRow> list = objectContext.select( q );
> ----------------------------------
> GENERATED SQL
> ----------------------------------
> SELECT t0.creation_date, t0.date, t0.modification_date, t0.shop_id, t0.storage_number, t0.text, t0.user_id, t0.id FROM strimillinn.fd_receipt t0



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)