FAQ
SQLTemplate and using setPageSize(): IllegalArgumentException when executing query
----------------------------------------------------------------------------------

Key: CAY-1093
URL: https://issues.apache.org/cayenne/browse/CAY-1093
Project: Cayenne
Issue Type: Bug
Components: Cayenne Core Library
Affects Versions: 2.0 [STABLE]
Environment: Cayenne 2.0.4, JDK 1.5.0_16 on Windows XP SP3, Database: Oracle 10g, Release 10.2.0.3.0
Reporter: Jens Mayer
Assignee: Andrus Adamchik


Using a paginated SQLTemplate like this:

SQLTemplate rawQuery = (SQLTemplate)dataCtx.getEntityResolver().lookupQuery("myQuery");
Map<String,Object> params = new HashMap<String,Object>();
params.put("myParameter", myID);
rawQuery.setParameters(params);
rawQuery.setPageSize(50);
List<?> protList = dataCtx.performQuery(rawQuery);

throws the following error:
java.lang.IllegalArgumentException: org.apache.cayenne.query.SelectQuery: "setRoot(..)" takes
a DataMap, String, ObjEntity, DbEntity, Procedure, or Class. It was passed a null
at org.apache.cayenne.query.AbstractQuery.setRoot(AbstractQuery.java:104)
at org.apache.cayenne.query.SelectQuery.init(SelectQuery.java:143)
at org.apache.cayenne.query.SelectQuery.(SelectQuery.java:72)
at org.apache.cayenne.access.IncrementalFaultList.(DataContextQueryAction.java:92)
at org.apache.cayenne.access.DataContextQueryAction.execute(DataContextQueryAction.java:50)
at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1395)
at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:1384)
..... more

additional infos:
- the query is mapped via the modeler
- "fetch Data Objects" in modeler is unchecked
- the query is'nt shared across multiple DataContexts
- cloning the query has no effect
- the exception isn't thrown when call of setPageSize() is omitted







--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Search Discussions

  • Anonymous at Aug 12, 2008 at 8:09 am
    [ https://issues.apache.org/cayenne/browse/CAY-1093?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13043#action_13043 ]

    Andrus Adamchik commented on CAY-1093:
    --------------------------------------

    I analyzed the problem (which I can reproduce, btw), and there is no way for the current pagination algorithm to build queries for row ranges to resolve pages, unless the query is based on an ObjEntity (even if the data rows are fetched). So for now I am just adding a more verbose error message to the IncrementalFaultList.

    There is a simple workaround though - map a generic ObjEntity to the query result ("generic" means you don't need to specify a Java class for it), which is in turn mapped to a fake DbEntity (unless there is a real one describing the result). Until the TODO below is addressed, you will have to flip the data rows flag back in the code:

    rawQuery.setFetchingDataRows(false);


    TODO: allow SQLTemplate to have a root entity in the DataRow mode in the Modeler (when data rows are selected, currently the entity dropdown is disabled and the root is set to DataMap).
    SQLTemplate and using setPageSize(): IllegalArgumentException when executing query
    ----------------------------------------------------------------------------------

    Key: CAY-1093
    URL: https://issues.apache.org/cayenne/browse/CAY-1093
    Project: Cayenne
    Issue Type: Bug
    Components: Cayenne Core Library
    Affects Versions: 2.0 [STABLE]
    Environment: Cayenne 2.0.4, JDK 1.5.0_16 on Windows XP SP3, Database: Oracle 10g, Release 10.2.0.3.0
    Reporter: Jens Mayer
    Assignee: Andrus Adamchik

    Using a paginated SQLTemplate like this:
    SQLTemplate rawQuery = (SQLTemplate)dataCtx.getEntityResolver().lookupQuery("myQuery");
    Map<String,Object> params = new HashMap<String,Object>();
    params.put("myParameter", myID);
    rawQuery.setParameters(params);
    rawQuery.setPageSize(50);
    List<?> protList = dataCtx.performQuery(rawQuery);
    throws the following error:
    java.lang.IllegalArgumentException: org.apache.cayenne.query.SelectQuery: "setRoot(..)" takes
    a DataMap, String, ObjEntity, DbEntity, Procedure, or Class. It was passed a null
    at org.apache.cayenne.query.AbstractQuery.setRoot(AbstractQuery.java:104)
    at org.apache.cayenne.query.SelectQuery.init(SelectQuery.java:143)
    at org.apache.cayenne.query.SelectQuery.<init>(SelectQuery.java:83)
    at org.apache.cayenne.query.SelectQuery.<init>(SelectQuery.java:72)
    at org.apache.cayenne.access.IncrementalFaultList.<init>(IncrementalFaultList.java:129)
    at org.apache.cayenne.access.DataContextQueryAction.interceptPaginatedQuery(DataContextQueryAction.java:92)
    at org.apache.cayenne.access.DataContextQueryAction.execute(DataContextQueryAction.java:50)
    at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1395)
    at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:1384)
    ..... more
    additional infos:
    - the query is mapped via the modeler
    - "fetch Data Objects" in modeler is unchecked
    - the query is'nt shared across multiple DataContexts
    - cloning the query has no effect
    - the exception isn't thrown when call of setPageSize() is omitted
    --
    This message is automatically generated by JIRA.
    -
    You can reply to this email to add a comment to the issue online.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categoriescayenne
postedAug 8, '08 at 6:56a
activeAug 12, '08 at 8:09a
posts2
users1
websitecayenne.apache.org

1 user in discussion

Anonymous: 2 posts

People

Translate

site design / logo © 2022 Grokbase