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

Albert Lee commented on OPENJPA-2502:
-------------------------------------

The NPE comes from the following code fragment in createKey() where 
q.getAccessPathMetaDatas() returns 
[null, test.Department] and subsequent meta.getDescribedType() on the first 
element takes the NPE.

        // we can't cache the query if we don't know which classes are in the
        // access path
        ClassMetaData[] metas = q.getAccessPathMetaDatas();
        if (metas.length == 0)
            return null;

        Set<String> accessPathClassNames = new HashSet<String>((int) 
(metas.length * 1.33 + 1));
        ClassMetaData meta;
        for (int i = 0; i < metas.length; i++) {
            // since the class change framework deals with least-derived types,
            // record the least-derived access path types
            meta = metas[i];
            accessPathClassNames.add(meta.getDescribedType().getName()); <<<< 
NPE
            while (meta.getPCSuperclass() != null) {
                meta = meta.getPCSuperclassMetaData(); 
            }

            accessPathClassNames.add(meta.getDescribedType().getName());
        }


> NPE in QueryKey.createKey using criteria with QueryCache enabled
> ----------------------------------------------------------------
>
>                 Key: OPENJPA-2502
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2502
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: criteria, datacache
>    Affects Versions: 2.2.1, 2.2.2
>            Reporter: Albert Lee
>         Attachments: OPENJPA-2502.test.zip
>
>
> Running an example in the spec using Criteria API with "left join fetch" AND 
> query cache enabled yield the following NPE exception. See the testcase to 
> reproduce the problem and the spec section where the example comes from:
> <openjpa-2.2.1.1-SNAPSHOT-r422266:1438134 nonfatal user error> 
> org.apache.openjpa.persistence.ArgumentException: Failed to execute query 
> "null". Check the query syntax for correctness. See nested exception for 
> details.
>       at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:872)
>       at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
>       at 
> org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
>       at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:286)
>       at 
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302)
>       at com.ibm.ws.persistence.QueryImpl.getResultList(QueryImpl.java:118)
>       at test.TestNPE.test(TestNPE.java:62)
> ......
> Caused by: java.lang.NullPointerException
>       at org.apache.openjpa.datacache.QueryKey.createKey(QueryKey.java:203)
>       at org.apache.openjpa.datacache.QueryKey.newInstance(QueryKey.java:139)
>       at 
> org.apache.openjpa.datacache.QueryCacheStoreQuery$QueryCacheExecutor.executeQuery(QueryCacheStoreQuery.java:339)
>       at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1005)
>       at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863)
>       ... 33 more



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to