Issue #521: query.getResultList() throws ClassCastException

Type: Bug ReoprtVersion: 2.3.0Priority: NormalStatus: FixedReplies: 3
#1

I modified the example code to include an index on the Point class like so:

    @Index(members={"x","y"})

Then when I run the following query:

    TypedQuery<Point> query = em.createQuery("SELECT p FROM Point p where p.x <= :x and p.y >= :y",
        Point.class);

I get the exception at the end.  I do not get an exception if I:

  • Use no index
  • Index only on "x"
  • Use an OR in the query instead of AND
[ObjectDB 2.3.0_04] Unexpected exception (Error 990)
  Generated by Java HotSpot(TM) 64-Bit Server VM 1.6.0_22 (on Windows 7 6.1).
Please report this error on http://www.objectdb.com/database/issue/new
com.objectdb.o.InternalException: java.lang.ClassCastException: com.objectdb.o.NLV cannot be cast to com.objectdb.o.CMV
java.lang.ClassCastException: com.objectdb.o.NLV cannot be cast to com.objectdb.o.CMV
at com.objectdb.o.VOB.l(VOB.java:218)
at com.objectdb.o.NFL.Uu(NFL.java:89)
at com.objectdb.o.SBI.u(SBI.java:109)
at com.objectdb.o.OBI.w(OBI.java:466)
at com.objectdb.o.OBI.<init>(OBI.java:188)
at com.objectdb.o.SBI.<init>(SBI.java:50)
at com.objectdb.o.MST.aU(MST.java:737)
at com.objectdb.o.BQI.Ut(BQI.java:123)
at com.objectdb.o.FQI.Ut(FQI.java:68)
at com.objectdb.o.PRG.ab(PRG.java:603)
at com.objectdb.o.QRM.US(QRM.java:259)
at com.objectdb.o.MST.US(MST.java:892)
at com.objectdb.o.WRA.US(WRA.java:290)
at com.objectdb.o.WSM.US(WSM.java:113)
at com.objectdb.o.QRR.g(QRR.java:232)
at com.objectdb.o.QRR.b(QRR.java:151)
at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:665)
at point.Main.main(Main.java:52)
#2

Thank you for this bug report and for the test. Version 2.3.1 fixes the exception.

Some performance tips for this test:

  • You can improve persist performance by using smaller transactions (commit per 50,000 objects) rather than one very large transaction of one million objects (because it would consume less RAM).
  • You can improve query performance by retrieving field values rather than entity objects (when applicable) because of the overhead of instantiating entity objects.
  • Make sure your classes are enhanced.
ObjectDB Support
#3

Thanks for the quick turn around, I'll try out 2.3.1.

In regards to the tips:

  • Yes I noticed this when I started pushing things into the millions, and had already modified accordingly.  I also noticed a flaw in my use of the generated 'id' before 'commit'.  This caused the ID lookups on non-existent entities to be "slow" due to an internal exception (thrown and caught I think) according to my profiler.  Once I fixed my test, the ID lookups are 5x+ faster on existent entities.
  • Ok, good to know.  I've already looked into enabling level 2 caching, to see how that affects things.  The full object is likely to be our common use case, rather than a projection.
  • I had made changes to use a configuration XML, and was running with agent="true" on JDK 6, so hopefully that's good enough.  I need to look into it more.

I'd like to look closer into the JPAB code, see what it actually tests.  I'm basically comparing ObjectDB JPA against ehcache lookups/queries.

 

#4

Build 2.3.1_04 includes a more complete fix for this problem (following issue #531).

ObjectDB Support

Reply