google-code-export / objectify-appengine

Automatically exported from code.google.com/p/objectify-appengine
MIT License
1 stars 0 forks source link

asSingle() produces NullPointerException when query returns no result #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. An empty database
2. query returns no result with 
3.
    OQuery<User> query = fact().createQuery(User.class);
    query.filter(column, param);
    User user = null;
    OPreparedQuery<User> pq = ofy().prepare(query);
    user = pq.asSingle();

What is the expected output? What do you see instead?
Expected returning null asSingle(), but we have a NPE:

java.lang.NullPointerException
    at
com.googlecode.objectify.OPreparedQueryImpl.asSingle(OPreparedQueryImpl.java:99)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java
:100)
    at
com.googlecode.objectify.DatastoreTimeoutRetryProxy.invoke(DatastoreTimeoutRetry
Proxy.java:54)
    at $Proxy8.asSingle(Unknown Source)
    at com.miracle.server.dao.UserDao.getUser(UserDao.java:51)
    at com.miracle.server.pe.Login.doPost(Login.java:57)
        ......

What version of the product are you using? On what operating system?
Objectify v1.0

Please provide any additional information below.

Original issue reported on code.google.com by zero...@gmail.com on 21 Jan 2010 at 12:06

GoogleCodeExporter commented 9 years ago
Fixed in 1.0.1

Original comment by lhori...@gmail.com on 25 Jan 2010 at 6:08