Using @Index for fields and combine this with sorting the query throws an NullPointerException. This code reproduces the error:
public class NullTest { @Entity @Indices({ @Index(members = {"children.name"}), @Index(members = {"children.age"}) }) static class Parent { String name; @Embedded List<Child> children; } @Embeddable static class Child { String name; Integer age; } public static void main(String[] args) { Child child = new Child(); child.name = "Foo"; child.age = 42; Parent parent = new Parent(); parent.name = "Bar"; parent.children = Collections.singletonList(child); EntityManagerFactory emf = Persistence.createEntityManagerFactory("foo.odb"); EntityManager em = emf.createEntityManager(); em.getTransaction().begin(); em.persist(parent); em.getTransaction().commit(); System.out.println(em.createQuery("select from Parent p join p.children c where c.age = 42 and c.name = 'Foo' order by name", Parent.class).getResultList().size()); } }
The Message thrown is:
com.objectdb.o.InternalException: java.lang.NullPointerException: Cannot invoke "com.objectdb.o.RFV.S()" because "<local9>" is null java.lang.NullPointerException: Cannot invoke "com.objectdb.o.RFV.S()" because "<local9>" is null at com.objectdb.o.PLN.ZG(PLN.java:564) at com.objectdb.o.TAI.ZG(TAI.java:203) at com.objectdb.o.TAI.Zn(TAI.java:136) at com.objectdb.o.XQI.Zn(XQI.java:57) at com.objectdb.o.GQI.Zn(GQI.java:123) at com.objectdb.o.SQI.Zn(SQI.java:110) at com.objectdb.o.PRG.h(PRG.java:698) at com.objectdb.o.PRG.g(PRG.java:560) at com.objectdb.o.QRM.ZP(QRM.java:287) at com.objectdb.o.MST.ZP(MST.java:1026) at com.objectdb.o.WRA.ZP(WRA.java:313) at com.objectdb.o.WSM.ZP(WSM.java:117) at com.objectdb.o.QRR.k(QRR.java:260) at com.objectdb.o.QRR.i(QRR.java:154) at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:726) at org.example.NullTest.main(NullTest.java:43)