Issue #2178: Internal exception: NPE on criteria query with IN clause and empty collection

Type: BugVersion: 2.7.3Priority: NormalStatus: FixedReplies: 1

Hello ObjectDB team,

I receive following exception in my application:

[ObjectDB 2.7.3_01] Unexpected exception (Error 990)
  Generated by Java HotSpot(TM) 64-Bit Server VM 1.8.0_66 (on Windows 10 10.0).
Please report this error on
com.objectdb.o.InternalException: java.lang.NullPointerException: null
at com.objectdb.o.QNF.l(
at com.objectdb.o.QNF.v(
at com.objectdb.o.QNF.p(
at com.objectdb.o.QNF.v(
at com.objectdb.o.QNF.w(
at com.objectdb.o.QRC.n(
at com.objectdb.o.QRC.t(
at com.objectdb.o.QRC.j(
at com.objectdb.o.QRM.ZE(
at com.objectdb.o.MST.ZE(
at com.objectdb.o.WRA.ZE(
at com.objectdb.o.WSM.ZE(
at com.objectdb.o.QRR.k(
at com.objectdb.o.QRR.i(
at com.objectdb.jpa.JpaQuery.getResultList(
at pl.hobsoft.lohare.server.BusinessService.createProvidingPersonAccount(
at pl.hobsoft.lohare.server.BusinessServiceTest.createProvidingPersonAccountTest(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
[... more JUnit stack frames...]

I've already narrowed the cause to the fact that I use JPA criteria query API, and I pass an empty collection to IN expression:

   CriteriaBuilder cb = em.getCriteriaBuilder();
   CriteriaQuery<Service> cq = cb.createQuery(Service.class);
   Root<Service> rootService = cq.from(Service.class);;
   cq.where(rootService.get("key").in(templateKeys)); //templateKeys is empty by mistake
   List<Service> services = em.createQuery(cq).getResultList();

As exception itself is nothing wrong here I guess (at least other JPA providers also throw on empty IN parameter), the exception message could be better, I believe.


Additionally, I would like to state that I would really love to see support for static metamodel in ObjectDB implementation of both JPA criteria API and JDO typed queries - it would make interoperability between ObjectDB and other JPA providers much better. Currently, when I implement parts of application with ObjectDB, and other parts with (for example) Hibernate, I cannot use static metamodel in common code :(


Best Regards,



Build 2.7.3_03 fixes the bug. Thank you for the report. 

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login