java.util.HashSet cannot be cast to java.lang.Comparable

522 views
Skip to first unread message

Jan-Hendrik Lendholt

unread,
Jan 7, 2013, 3:26:38 AM1/7/13
to orient-...@googlegroups.com
Hi there, me again.

I still have classA and classB which represents a one-to-many relationship.

classA has properties name and description. It keeps its relationships to classB in a property "events" which is modeled as a linklist. class b has eventName and fromTime and toTime.

Now when I execute:

select * from classA where name like '%ANY_SLUG%' and events.fromTime <= date('1970-01-01T01:00:00.000Z', 'yyyy-MM-dd'T'HH:mm:ss.SSS'Z'') and events.toTime <= date('1970-01-01T01:00:00.001Z', 'yyyy-MM-dd'T'HH:mm:ss.SSS'Z'') I get that nice little one here:









java.lang.ClassCastException: java.util.HashSet cannot be cast to java.lang.Comparable


        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)


        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)


        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)


        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)


        at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.createException(OChannelBinary.java:517)


        at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.handleStatus(OChannelBinary.java:470)


        at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:145)


        at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:59)


        at com.orientechnologies.orient.client.remote.OStorageRemote.beginResponse(OStorageRemote.java:1832)


        at com.orientechnologies.orient.client.remote.OStorageRemote.command(OStorageRemote.java:999)


        at com.orientechnologies.orient.client.remote.OStorageRemoteThread.command(OStorageRemoteThread.java:241)


        at com.orientechnologies.orient.core.sql.query.OSQLQuery.run(OSQLQuery.java:69)


        at com.orientechnologies.orient.core.sql.query.OSQLSynchQuery.run(OSQLSynchQuery.java:78)


        at com.orientechnologies.orient.core.query.OQueryAbstract.execute(OQueryAbstract.java:32)


        at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.query(ODatabaseRecordAbstract.java:447)


        at com.orientechnologies.orient.core.db.ODatabaseRecordWrapperAbstract.query(ODatabaseRecordWrapperAbstract.java:187)


        at com.timerange.dao.RangeDao.executeSlugSelect(RangeDao.java:32)


        at com.timerange.services.TimerangeService.findRangeBySlugAndTimeRestriction(TimerangeService.java:37)


        at com.timerange.services.TimerangeService$$FastClassByCGLIB$$4c7f8dea.invoke(<generated>)


        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)


        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)


        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)


        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)


        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)


        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)


        at com.timerange.services.TimerangeService$$EnhancerByCGLIB$$a0a6a2a1.findRangeBySlugAndTimeRestriction(<generated>)


        at com.timerange.web.controller.rest.FindRangeController$2.call(FindRangeController.java:72)


        at com.timerange.web.controller.rest.FindRangeController$2.call(FindRangeController.java:1)


        at org.springframework.web.context.request.async.WebAsyncManager$4.run(WebAsyncManager.java:318)


        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)


        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)


        at java.util.concurrent.FutureTask.run(FutureTask.java:166)


        at java.lang.Thread.run(Thread.java:722)


Any idea what that means? Is it related to my data model, the data contained, the query or something else?

Thanks!

Luca Garulli

unread,
Jan 7, 2013, 5:42:28 AM1/7/13
to orient-database
Hi,
the problem seems to be in the type Set used in a comparison. Now since the only comparisons in your query are against times I guess the events is the set.

If what you want is what I believe this could be the solution: check inside the collection with the CONTAINS operator:

select *
from classA
where name like '%ANY_SLUG%'
 and events contains(
   fromTime <= date('1970-01-01T01:00:00.000Z', 'yyyy-MM-dd'T'HH:mm:ss.SSS'Z'')
   and toTime <= date('1970-01-01T01:00:00.001Z', 'yyyy-MM-dd'T'HH:mm:ss.SSS'Z''
  )


Lvc@

On 7 January 2013 09:26, Jan-Hendrik Lendholt <jan.le...@googlemail.com> wrote:
data

Jan-Hendrik Lendholt

unread,
Jan 7, 2013, 6:32:53 AM1/7/13
to orient-...@googlegroups.com
Sorry,

either I am blind or completely dumb.

This is the adapted query:

select * from Timerange where name like '%Wullf%' and events contains(fromTime <= date('1970-01-01T01:00:00.000Z', 'yyyy-MM-dd'T'HH:mm:ss.SSS'Z'') and toTime <= date('1970-01-01T01:00:00.001Z', 'yyyy-MM-dd'T'HH:mm:ss.SSS'Z''))


Now it tells me: Found invalid ) character. Ensure it is opened and closed correctly. But the braackets are closed correctly, aren't they? If I remove the last bracket, I receive the exception: Error on conversion of date 'false' using the format: yyyy-MM-dd


Which seems logical to me as a bracket is missing.


Sorry for bugging you and thanks a lot for your quick responses.

Luca Garulli

unread,
Jan 7, 2013, 6:47:06 AM1/7/13
to orient-database
Hi,
the SQL parser is too much "sensible" to spaces. We've some issue against this but usually everything is fixed just using spaces before/after parenthesis. Try this:

select * from Timerange where name like '%Wullf%' and events contains ( fromTime <= date('1970-01-01T01:00:00.000Z', 'yyyy-MM-dd'T'HH:mm:ss.SSS'Z'' ) and toTime <= date('1970-01-01T01:00:00.001Z', 'yyyy-MM-dd'T'HH:mm:ss.SSS'Z'') )


Luca Garulli
CEO at NuvolaBase.com
the Company behind OrientDB



--
 
 
 

Jan-Hendrik Lendholt

unread,
Jan 7, 2013, 6:57:39 AM1/7/13
to orient-...@googlegroups.com
You're my man, that worked! ODB looks really really promising. Just filled up with a few million datasets (okay, took me some hours) and still very fast. Nice :)

Luca Garulli

unread,
Jan 7, 2013, 7:12:42 AM1/7/13
to orient-database
Great! To stay fast even with billions of record remember to use the Graph capabilities and indexes as less as you can.

Lvc@


On 7 January 2013 12:57, Jan-Hendrik Lendholt <jan.le...@googlemail.com> wrote:
You're my man, that worked! ODB looks really really promising. Just filled up with a few million datasets (okay, took me some hours) and still very fast. Nice :)

--
 
 
 

Reply all
Reply to author
Forward
0 new messages