映射文件如下:
<?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>
<class name="cn.com.una.hr.time.model.TimeWatchCompanyStat">
<property name="companyStatId"/>
<property name="organizationId"/>
<property name="chineseShortName"/>
<property name="watchSubsidyMonth"/>
<property name="wacthDateMonth"/>
<property name="wacthEmployeeMonth"/>
<property name="salaryCountMonth"/>
<property name="salaryCountYear"/>
<property name="salaryCountCompleted"/>
<property name="auditorId"/>
<property name="chineseName"/>
<property name="auditDate"/>
<property name="auditFlag"/>
<loader query-ref="TimeWatchCompanyStatSQL"/>
</class>
<sql-query name="TimeWatchCompanyStatSQL">
<![CDATA[
SELECT
SALARY_COUNT_MONTH||SALARY_COUNT_YEAR||T1.ORGANIZATION_ID as {c.companyStatId},
T1.ORGANIZATION_ID as {c.organizationId},
T_ORG.CHINESE_SHORT_NAME as {c.chineseShortName},
SUM(WATCH_SUBSIDY) AS WATCH_SUBSIDY_MONTH as {c.watchSubsidyMonth},
COUNT(WATCH_DATE) AS WATCH_DATE_MONTH as {c.wacthDateMonth},
(SELECT COUNT(DISTINCT EMPLOYEE_ID) FROM HR_TIME_WATCH T2
WHERE T1.ORGANIZATION_ID = T2.ORGANIZATION_ID ) AS WATCH_EMPLOYEE_MONTH as {c.wacthEmployeeMonth},
SALARY_COUNT_MONTH as {c.salaryCountMonth},
SALARY_COUNT_YEAR as {c.salaryCountYear},
SALARY_COUNT_COMPLETED as {c.salaryCountCompleted},
AUDITOR_ID as {c.auditorId},
T_EMP.CHINESE_NAME as {c.chineseName},
AUDIT_DATE as {c.auditDate},
AUDIT_FLAG as {c.auditFlag}
FROM HR_TIME_WATCH T1 ,
UM_ORGANIZATION T_ORG ,
UM_EMPLOYEE T_EMP
WHERE
T1.ORGANIZATION_ID = T_ORG.ORGANIZATION_ID AND
T1.AUDITOR_ID = T_EMP.EMPLOYEE_ID(+) AND
T1.DELETED = 0
GROUP BY
T1.ORGANIZATION_ID ,
T_ORG.CHINESE_SHORT_NAME ,
SALARY_COUNT_MONTH ,
SALARY_COUNT_YEAR ,
SALARY_COUNT_COMPLETED ,
AUDITOR_ID ,
T_EMP.CHINESE_NAME ,
AUDIT_DATE ,
AUDIT_FLAG]]>
<return alias="c" class="cn.com.una.hr.time.model.TimeWatchCompanyStat"/>
</sql-query>
</hibernate-mapping>
<?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>
<class name="cn.com.una.hr.time.model.TimeWatchCompanyStat">
<property name="companyStatId"/>
<property name="organizationId"/>
<property name="chineseShortName"/>
<property name="watchSubsidyMonth"/>
<property name="wacthDateMonth"/>
<property name="wacthEmployeeMonth"/>
<property name="salaryCountMonth"/>
<property name="salaryCountYear"/>
<property name="salaryCountCompleted"/>
<property name="auditorId"/>
<property name="chineseName"/>
<property name="auditDate"/>
<property name="auditFlag"/>
<loader query-ref="TimeWatchCompanyStatSQL"/>
</class>
<sql-query name="TimeWatchCompanyStatSQL">
<![CDATA[
SELECT
SALARY_COUNT_MONTH||SALARY_COUNT_YEAR||T1.ORGANIZATION_ID as {c.companyStatId},
T1.ORGANIZATION_ID as {c.organizationId},
T_ORG.CHINESE_SHORT_NAME as {c.chineseShortName},
SUM(WATCH_SUBSIDY) AS WATCH_SUBSIDY_MONTH as {c.watchSubsidyMonth},
COUNT(WATCH_DATE) AS WATCH_DATE_MONTH as {c.wacthDateMonth},
(SELECT COUNT(DISTINCT EMPLOYEE_ID) FROM HR_TIME_WATCH T2
WHERE T1.ORGANIZATION_ID = T2.ORGANIZATION_ID ) AS WATCH_EMPLOYEE_MONTH as {c.wacthEmployeeMonth},
SALARY_COUNT_MONTH as {c.salaryCountMonth},
SALARY_COUNT_YEAR as {c.salaryCountYear},
SALARY_COUNT_COMPLETED as {c.salaryCountCompleted},
AUDITOR_ID as {c.auditorId},
T_EMP.CHINESE_NAME as {c.chineseName},
AUDIT_DATE as {c.auditDate},
AUDIT_FLAG as {c.auditFlag}
FROM HR_TIME_WATCH T1 ,
UM_ORGANIZATION T_ORG ,
UM_EMPLOYEE T_EMP
WHERE
T1.ORGANIZATION_ID = T_ORG.ORGANIZATION_ID AND
T1.AUDITOR_ID = T_EMP.EMPLOYEE_ID(+) AND
T1.DELETED = 0
GROUP BY
T1.ORGANIZATION_ID ,
T_ORG.CHINESE_SHORT_NAME ,
SALARY_COUNT_MONTH ,
SALARY_COUNT_YEAR ,
SALARY_COUNT_COMPLETED ,
AUDITOR_ID ,
T_EMP.CHINESE_NAME ,
AUDIT_DATE ,
AUDIT_FLAG]]>
<return alias="c" class="cn.com.una.hr.time.model.TimeWatchCompanyStat"/>
</sql-query>
</hibernate-mapping>
解决方案 »
- 意见征求【javaEE工程师等级评定】,恳求各位高手完善。
- 寻找Java操作AutoCAD的Java开源软件或者IE的Active插件
- myeclipse中使用webservice生成的客户端如何设超时?
- flex中如何动态填充颜色
- struts + spring + hiberante整合问题
- 关于调用快捷键……急急急!80分求答案
- 现在开发java方面的分布式系统一般用什么?
- 急救:Stack size too large 是什么错误?请帮忙,不甚感激
- weblogic配置
- BMP的初学者问题!??请有过次方面经验的人不吝指教!!多谢!
- 请教Hibernate多表操作的例子
- 这样一个三元的多对多关系该如何设计与映射?
hibernate原理??是一本书吗?
偶现在只想将SQL查询结果映射成一个对象而已,
虽然我的映射文件应该是有错误,不过并未到彪悍的程度啊
映射不一定要与实际的数据库表映射,另外我只是把SQL写在映射文件中而已。
不是持久化类,只是作为临时对象处理,并不需要写映射文件那么临时对象应该如何建立??谢谢