I am doing a sql where I am trying to perform a cast of a boolean to an integer and I am getting a weird error. Thanks for any help.
Here is my hql:(this is a simplified version i am testing with doesn't accomplish anything)
Quote:
select treatmentCourse.id, cast(todos.done as integer) from TreatmentCourse treatmentCourse left outer join treatmentCourse.todos as todos group by treatmentCourse.id
todos.done is a boolean value and I want to cast it to an integer. The reason is so I can do a sum(cast(todos.don as integer)). I am using hsqldb and I have tried this sql out directly on the db and it works fine. But not through hibernate.
Here is the error I am getting:
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.MethodNode
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'cast' {originalText=cast}
\-[EXPR_LIST] SqlNode: 'exprList'
+-[DOT] DotNode: 'todos1_.DONE' {propertyName=done,dereferenceType=4,propertyPath=done,path=todos.done,tableAlias=todos1_,className=com.mbs.model.domainobjects.documentation.Todo,classAlias=todos}
| +-[ALIAS_REF] IdentNode: 'todos1_.ID' {alias=todos, className=com.mbs.model.domainobjects.documentation.Todo, tableAlias=todos1_}
| \-[IDENT] IdentNode: 'done' {originalText=done}
\-[IDENT] IdentNode: 'integer' {originalText=integer}
Here is the mapping file for Todo:
Quote:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="true">
<class name="com.mbs.model.domainobjects.documentation.Todo" table="TODOS" >
<id name="id" column="ID" type="int" unsaved-value="-1" access="field">
<generator class="identity"/>
</id>
<version name="version" column="VERSION" unsaved-value="negative" access="field"/>
<property name="companyId" column="COMPANY_ID" not-null="true" access="field"/>
<property name="createDate" column="CREATE_DATE" not-null="true" type="date"/>
<property name="userId" column="USER_ID" not-null="true"/>
<property name="summary" column="SUMMARY" not-null="true"/>
<property name="done" column="DONE" access="field" type="boolean"/>
<property name="dateDone" column="DATE_DONE" type="date" access="field"/>
<property name="patientId" column="PATIENT_ID" not-null="true"/>
<property name="account" column="ACCOUNT" />
<property name="note" column="NOTE" />
<property name="treatmentCourseId" column="TREATMENT_COURSE_ID" />
<property name="serviceLineId" column="SERVICE_LINE_ID" />
</class>
</hibernate-mapping>