Issue #531: ClassCastException thrown when running count query

Type: Bug ReoprtPriority: NormalStatus: FixedReplies: 6
#1

Hello!

Attached you find a full stacktrace.

The query was:

SELECT COUNT(t) FROM Position t
WHERE ((t.unit = :unit165w7ppbtu9ao AND t.receiveTime >= :receiveTimes232ne30kd42)
AND (t.latitude > :latitudehjgtlyt6s6dg AND t.longitude > :longitude14pwryko038jd))

The strange thing is that it only happens with certain values for the unit parameter. It's limited to some (not all!) of the newer units i have inserted. I'm currently evaluating your product. So i insert and delete a lot of data. I also tried to run your DB Doctor. It doesn't help.

Please contact me if you need more informations.

Regards

Ralph Moser

#2

The exception is in code that was modified in the last build 2.3.1_03. Although I don't see how the change is relevant - you may want to try running your test with build 2.3.1.

It would be very helpful if you can provide a test database + parameters that cause the exception (possibly in a support ticket if you can share the database but you don't want to make it public).

If it is not possible - please provide more information, particularly:

  • Index definition for the fields in the query.
  • Log of the query execution using DEBUG logging level.
ObjectDB Support
#3

Hello again!

I had the same issue with 2.3.1_02. I updated after the bug occoured.

After some experimenting i found a way for you to reproduce the crash.
If you open the attached db with the explorer and run the query below it will crash with the exception in crash.txt.

select p from Position p where p.unit.unitID = :id

:id = 101

The exception looks different (embedded vs server mode) but i think it has the same reason.

Please keep the database confidential!

Regards

Ralph

#4

It doesn't look as the same exception.

At least this one seems to be related to broken references. The Doctor detects many broken references in this database. Notice that currently ObjectDB doesn't enforce reference integrity and it is the application responsibility to avoid deletion from the database of objects that are still referenced by other objects.

Can I run the first query on this database? Could you please provide the parameter values for getting the first exception?

ObjectDB Support
#5

I could fix ObjectDB to return correct results for the second query (even though there are broken references).

The first query also runs well now with parameters 0, 0, 0, Unit#2074.

Please provide additional parameters for testing the first query and if the problem is solved a new build with the fix will be produced.

ObjectDB Support
#6

The orphan Position records are there because i deleted some Units with a DELETE Query. Then i realized that the cascade option in the entity class is ignored when doing DELETE. I then tried to delete the orphans. Without success.

Try this query:

DELETE FROM Position p WHERE p.unit IS NULL

It doesn't delete anything. If you try it with SELECT nothing get's returned.

It's even getting better:

SELECT p FROM Position p WHERE p.unit IS NOT NULL

This query produces a null pointer exception.

Now back to the count query:

SELECT COUNT(t) FROM Position t
WHERE ((t.unit = :unit AND t.receiveTime >= :receiveTime)
AND (t.latitude > :latitude AND t.longitude > :longitude))

Try this parameters:

latitude and longitude = 0.001
unit = Unit#1974
receiveTime = 0

The result is this error:

Query Execution Error
=====================
com.objectdb.o.RFV cannot be cast to com.objectdb.o.CMV

If we can sort out this problems i will swich my project to your product. It's really fast.

#7

Please try build 2.3.1_04 that should fix these exceptions.

For the following query to take effect:

DELETE FROM Position p WHERE p.unit IS NULL

You first have to run the Doctor in fix mode and that will replace broken references with null values (because broken references are not null values).

ObjectDB Support

Reply