My problem is basically that a ClassCastException occurs in the core of Hibernate when I used a HQL query containing a WHERE clause with an "=" sign in it. Here follows more info. The full stack trace is at the bottom. Am I doing some thing wrong or is there a bug in Hibernate?
Hibernate version: 3.2.1
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="nl.semlab.meditra.nts.viewer.model.call" default-lazy="false">
<class name="CallData" table="calls">
<id name="id" column="callId" type="long" unsaved-value="-1">
<generator class="native" />
</id>
<many-to-one name="session" column="sessionId"
class="nl.semlab.meditra.nts.viewer.model.session.SessionData" />
<many-to-one name="patient" column="patId"
class="nl.semlab.meditra.nts.viewer.model.patient.Patient" />
<property name="extCallId" type="string" length="128" />
<property name="userName" type="string" length="64" />
<property name="startCall" type="timestamp" />
<property name="finishTriage" type="timestamp" />
<property name="finishCall" type="timestamp" />
<property name="subjective" type="text" />
<property name="protocolUrgency" type="string" length="16" />
<property name="userUrgency" type="string" length="16" />
<property name="motivationUrgency" type="text" />
<property name="protocolFollowup" type="string" length="16" />
<property name="userFollowup" type="string" length="16" />
<property name="motivationFollowup" type="text" />
<property name="userAdvice" type="text" />
<property name="xmlResult" type="text" />
<!-- we do nothing with the stuff below, other than pass it along to the database -->
<property name="patientLocation" type="string" />
<property name="inputTime">
<type name="nl.semlab.meditra.nts.viewer.model.util.HibEnumUserType">
<param name="enumClassName">
nl.semlab.meditra.nts.viewer.model.util.EnumInputTime
</param>
</type>
</property>
<property name="timeEntry" type="timestamp" />
<property name="timeTreatment" type="timestamp" />
<property name="timeLeaveLocation" type="timestamp" />
<bag name="defaultAdvice" cascade="all">
<key column="callId" />
<one-to-many
class="nl.semlab.meditra.nts.viewer.model.advies.AdviceItem" />
</bag>
<bag name="usedExperts" cascade="all">
<key column="callId" />
<one-to-many
class="nl.semlab.meditra.nts.viewer.model.expert.UsedExpert" />
</bag>
<bag name="usedVariables" cascade="all">
<key column="callId" />
<one-to-many
class="nl.semlab.meditra.nts.viewer.model.variable.UsedVariable" />
</bag>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
One simple line:
Code:
results = session.createQuery(query).setFirstResult(page * pageSize).setMaxResults(pageSize + 1).list();
Where the query is the following string:
Quote:
"FROM CallData c WHERE c.startCall >= '2007-11-06' AND c.startCall <= '2007-11-20'"
Full stack trace of any exception that occurs:
java.lang.ClassCastException: org.hibernate.hql.ast.HqlToken cannot be cast to antlr.Token
at antlr.CharScanner.makeToken(CharScanner.java:173)
at org.hibernate.hql.ast.HqlLexer.makeToken(HqlLexer.java:39)
at org.hibernate.hql.antlr.HqlBaseLexer.mIDENT(HqlBaseLexer.java:580)
at org.hibernate.hql.antlr.HqlBaseLexer.nextToken(HqlBaseLexer.java:264)
at antlr.TokenBuffer.fill(TokenBuffer.java:69)
at antlr.TokenBuffer.LA(TokenBuffer.java:80)
at antlr.LLkParser.LA(LLkParser.java:52)
at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:139)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:248)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at nl.semlab.meditra.nts.viewer.calltable.swing.paging.Page.<init>(Page.java:41)
at nl.semlab.meditra.nts.viewer.calltable.commands.paging.ShowPage.showPage(ShowPage.java:36)
at nl.semlab.meditra.nts.viewer.calltable.commands.paging.ShowFirstPage.execute(ShowFirstPage.java:33)
at nl.semlab.meditra.nts.viewer.calltable.swing.paging.PagingPanel.update(PagingPanel.java:111)
at nl.semlab.observer.WeakObservable.notifyObservers(WeakObservable.java:263)
at nl.semlab.meditra.nts.viewer.calltable.swing.paging.PagingModel.setWhereClause(PagingModel.java:148)
at nl.semlab.meditra.nts.viewer.calltable.commands.FilterPeriod.execute(FilterPeriod.java:61)
at nl.semlab.meditra.nts.viewer.calltable.swing.datefilter.DatePanel$PeriodsActionListener.actionPerformed(DatePanel.java:158)
at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1242)
at javax.swing.JComboBox.setSelectedItem(JComboBox.java:569)
at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:605)
at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPopup.java:814)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:273)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(BasicComboPopup.java:480)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Name and version of the database you are using:
MSSQL 2005.
The generated SQL (show_sql=true):
It doesn't come to that.
Best regards,
Jethro Borsje