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

#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 http://www.objectdb.com/database/issue/new
com.objectdb.o.InternalException: java.lang.NullPointerException: null
java.lang.NullPointerException
at com.objectdb.o.QNF.l(QNF.java:1294)
at com.objectdb.o.QNF.v(QNF.java:316)
at com.objectdb.o.QNF.p(QNF.java:1267)
at com.objectdb.o.QNF.v(QNF.java:211)
at com.objectdb.o.QNF.w(QNF.java:136)
at com.objectdb.o.QRC.n(QRC.java:350)
at com.objectdb.o.QRC.t(QRC.java:239)
at com.objectdb.o.QRC.j(QRC.java:190)
at com.objectdb.o.QRM.ZE(QRM.java:273)
at com.objectdb.o.MST.ZE(MST.java:1001)
at com.objectdb.o.WRA.ZE(WRA.java:313)
at com.objectdb.o.WSM.ZE(WSM.java:117)
at com.objectdb.o.QRR.k(QRR.java:249)
at com.objectdb.o.QRR.i(QRR.java:155)
at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:721)
at pl.hobsoft.lohare.server.BusinessService.createProvidingPersonAccount(BusinessService.java:93)
at pl.hobsoft.lohare.server.BusinessServiceTest.createProvidingPersonAccountTest(BusinessServiceTest.java:68)
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(FrameworkMethod.java:50)
[... 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.select(rootService);
   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,

   Maciek

#2

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