Hibernate version:
2.1.6 ( MySQL DB )
Mapping documents:
Code:
<class name="com.fis.om.Task" discriminator-value="20">
<id column="id" name="id">
<generator class="native" />
</id>
<discriminator column="discriminator" type="byte" />
<property name="completionDate">
<column name="completionDate" sql-type="DATETIME" />
</property>
<property name="approvalDate">
<column name="approvalDate" sql-type="DATETIME" />
</property>
<property name="name">
<column name="name" sql-type="VARCHAR( 100 ) COLLATE utf8_general_ci" />
</property>
<property name="description">
<column name="description" sql-type="TEXT COLLATE utf8_general_ci" />
</property>
<property name="type" type="com.fis.om.TaskType" />
<many-to-one name="company" class="com.fis.om.Company" />
<many-to-one name="originator" class="com.fis.om.Employee" />
<many-to-one name="owner" class="com.fis.om.Employee" />
<set name="history"
lazy="true"
order-by="creationDate desc"
cascade="delete"
>
<key column="task" />
<one-to-many class="com.fis.om.TaskHistory" />
</set>
<subclass name="com.fis.om.PointTask" discriminator-value="21">
<property name="assignedDate">
<column name="assignedDate" sql-type="DATE" />
</property>
<property name="assignedTime">
<column name="assignedTime" sql-type="TIME" />
</property>
</subclass>
<subclass name="com.fis.om.SliceTask" discriminator-value="22">
<many-to-one name="slice" class="com.fis.om.TimeSlice" />
</subclass>
</class>
How can I do something like instanceof and dynamic casts in HQL? I need a query like
Code:
"FROM Task AS t" +
" WHERE" +
" IF(" +
" t instanceof SliceTask," +
" ( ( SliceTask )t ).slice.date >= :start," +
" ( ( PointTask )t ).assignedDate >= :start" +
" )" +
" ORDER BY" +
" t.completionDate IS NULL ASC"