My hierarchy HBM file is as follows. When I do a findHierarchyQuery, I want to be able to return an additional parameter back to the service. For now, let's say I want to return count(1) as Count. I have an extra field called Count in my DTO which is not present in the Hierarchy table. I want to add a query which returns a Count along with the table contents. Just to reiterate, my DTO has 1 extra field called Count in addition to add the fields in the table. So if I want to add a query like
Code:
<query name="findHierarchyQuery">
<![CDATA[
Select Hierarchy h, count(1) as Count from Hierarchy h
where h.code = :Code
]]>
</query>
How would I make sure that the Count from the query is being read by the DTO setter?
Code:
<?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="xxx.xxx.dto"
default-lazy="true">
<class name="Hierarchy" table="HIERARCHY"
dynamic-update="true">
<id name="id" column="HIERARCHYID" type="integer"
unsaved-value="null">
<generator class="native">
<param name="sequence">HIERARCHYSEQ</param>
</generator>
</id>
<version name="hibernateVersionId" column="VERSIONNUM"
type="integer" />
<property name="HierarchyLevel" column="HIERARCHYLEVEL"
type="integer"/>
</class>
<query name="findHierarchyQuery">
<![CDATA[
from Hierarchy h
where h.code = :Code
]]>
</query>