Issue #521: query.getResultList() throws ClassCastException

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

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


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",

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
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(
at com.objectdb.o.NFL.Uu(
at com.objectdb.o.SBI.u(
at com.objectdb.o.OBI.w(
at com.objectdb.o.OBI.<init>(
at com.objectdb.o.SBI.<init>(
at com.objectdb.o.MST.aU(
at com.objectdb.o.BQI.Ut(
at com.objectdb.o.FQI.Ut(
at com.objectdb.o.PRG.ab(
at com.objectdb.o.QRM.US(
at com.objectdb.o.MST.US(
at com.objectdb.o.WRA.US(
at com.objectdb.o.WSM.US(
at com.objectdb.o.QRR.g(
at com.objectdb.o.QRR.b(
at com.objectdb.jpa.JpaQuery.getResultList(
at point.Main.main(

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

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.



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

ObjectDB Support