Skip to content

Instantly share code, notes, and snippets.

@pomu0325
Created April 21, 2011 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pomu0325/934753 to your computer and use it in GitHub Desktop.
Save pomu0325/934753 to your computer and use it in GitHub Desktop.
NullPointerException at org.slim3.datastore.ModelQuery.asQueryResultList(ModelQuery.java:295)
package pomu0325.model;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.slim3.datastore.Datastore;
import org.slim3.datastore.S3QueryResultList;
import org.slim3.tester.AppEngineTestCase;
import pomu0325.meta.PersonMeta;
public class PersonTest extends AppEngineTestCase {
@Test
public void test() throws Exception {
Person pomu0325 = new Person();
pomu0325.getSkill().add("Java");
pomu0325.getSkill().add("Scala");
Datastore.put(pomu0325);
PersonMeta meta = PersonMeta.get();
S3QueryResultList<Person> result1
= Datastore.query(meta).filter(meta.skill.in("Java")).asQueryResultList();
assertThat(result1.size(), is(1));
// NullPointerException is thrown at asQueryResultList() when using InCriterion with 2 or more values...
// at org.slim3.datastore.ModelQuery.asQueryResultList(ModelQuery.java:295)
S3QueryResultList<Person> result2
= Datastore.query(meta).filter(meta.skill.in("Java", "Scala")).asQueryResultList();
assertThat(result2.size(), is(1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment