Issue Details (XML | Word | Printable)

Key: NUCJPA-146
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Unassigned
Reporter: Oliver Ringel
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus API JPA

JPQL TypedQuery throws NPE

Created: 14/Jul/11 11:42 PM   Updated: 13/Aug/12 03:16 PM   Resolved: 19/Jul/11 06:03 PM
Component/s: API
Affects Version/s: 3.0.0.m6
Fix Version/s: 3.0.0.release

File Attachments: 1. File testcase-datanucleus-nucjpa-146.tar (3 kB)


Datastore: Apache Derby


 Description  « Hide
Executing this TypedQuery

   List<Person> list = em.createQuery("SELECT p FROM Person p", Person.class).getResultList();

throws a NullPointerException.

Caused by: java.lang.NullPointerException
at org.datanucleus.query.QueryUtils.createResultObjectUsingDefaultConstructorAndSetters(QueryUtils.java:277)
at org.datanucleus.store.rdbms.query.ResultClassROF.getObject(ResultClassROF.java:364)
at org.datanucleus.store.rdbms.query.ForwardQueryResult.nextResultSetElement(ForwardQueryResult.java:171)
at org.datanucleus.store.rdbms.query.ForwardQueryResult$QueryResultIterator.next(ForwardQueryResult.java:375)
at org.datanucleus.store.rdbms.query.ForwardQueryResult.processNumberOfResults(ForwardQueryResult.java:133)
at org.datanucleus.store.rdbms.query.ForwardQueryResult.advanceToEndOfResultSet(ForwardQueryResult.java:154)
at org.datanucleus.store.rdbms.query.ForwardQueryResult.closingConnection(ForwardQueryResult.java:256)
... 38 more

Executing the same JPQL statement as an untyped Query together with a cast works.

   List<Person> list = (List<Person>) em.createQuery("SELECT p FROM Person p").getResultList();

It seems that in case of a typed Query the selection of an entity field is required, for example the following query
also works.

   List<String> list = em.createQuery("SELECT p.name FROM Person p", String.class).getResultList();


Sort Order: Ascending order - Click to sort in descending order
Oliver Ringel added a comment - 14/Jul/11 11:52 PM
testcase


Chris Rued added a comment - 23/Feb/12 06:27 PM
I'm getting a similar problem using MongoDB as a datastore:

java.lang.NullPointerException
at org.datanucleus.query.evaluator.JavaQueryEvaluator.execute(JavaQueryEvaluator.java:293)
at org.datanucleus.store.mongodb.query.JPQLQuery.performExecute(JPQLQuery.java:326)
at org.datanucleus.store.query.Query.executeQuery(Query.java:1791)
at org.datanucleus.store.query.Query.executeWithMap(Query.java:1694)
at org.datanucleus.api.jpa.JPAQuery.getResultList(JPAQuery.java:185)

Should I file this as a separate issue?



Andy Jefferson added a comment - 23/Feb/12 07:49 PM
This was an issue in the RDBMS plugin (only) so yours is totally unrelated, hence raise anything on the plugin (Mongodb) it relates to ... with testcase of course. In your case you're using in-memory evaluation so it may get moved to that, but just raise for MongoDB