问题描述
刚接触IBATIS,希望大家能够帮忙看一下.<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd"><sqlMap><typeAlias type="flex.samples.spring.dao.DailyReportBean" alias="dailyreport"/><resultMap class="dailyreport" id="rltPrintMonthReport"><result property="day" column="day"/><result property="starttime" column="starttime"/><result property="endtime" column="endtime"/><result property="worktime" column="worktime"/><result property="workcontent" column="workcontent"/><result property="department" column="department"/><result property="team" column="team"/><result property="confirm" column="confirm"/></resultMap> <select id="selPrintMonthReport" resultMap="rltPrintMonthReport" parameterClass="dailyreport">select ltrim(substr(report_date,7,2),0) day, min(starttime) starttime, max(endtime) endtime, case when min(starttime)<='12:00' and max(endtime)<='12:00' then (to_date(max(endtime),'hh24:mi')-to_date(min(starttime),'hh24:mi'))*24 when (min(starttime)>='12:00' and min(starttime)<='13:00') and (max(endtime)>='12:00' and max(endtime)<='13:00') then 0 when min(starttime)>='13:00' and max(endtime)>='13:00' then (to_date(max(endtime),'hh24:mi')-to_date(min(starttime),'hh24:mi'))*24 when min(starttime)<='12:00' and (max(endtime)>='12:00' and max(endtime)<='13:00') then (to_date('12:00','hh24:mi')-to_date(min(starttime),'hh24:mi'))*24 when min(starttime)<='12:00' and max(endtime)>='13:00' then (to_date(max(endtime),'hh24:mi')-to_date(min(starttime),'hh24:mi'))*24-1 when (min(starttime)>='12:00' and min(starttime)<='13:00') and max(endtime)>='13:00' then (to_date(max(endtime),'hh24:mi')-to_date('13:00','hh24:mi'))*24 end worktime, report_date,substr(max(sys_connect_by_path(workcontent,',')),2) workcontent, max(department) department, max(team) team, max(confirm) confirm from (select dailyreport.*,row_number() over(partition by report_date order by workcontent) rn from dailyreport) where login_id=#loginid# and substr(report_date,0,6)=#reportdate# group by report_date start with rn=1 connect by rn-1=prior rn and report_date=prior report_date </select></sqlMap>问题:如粗体红色部分所示,IBATIS中这样写报错.在网上查了一下,除等于外一般用动态SQL这种写法<isGreaterThan prepend=" and " property="??" compareValue="???">问题是我的写在CASE WHEN 语句中,应该怎么样修改....迷茫中...等待大好人....
解决方案
http://www.iteye.com/problems/624这个里面有答案.. 哈哈
解决方案二:
因为这个是xml格式的,所以不允许出现类似“>”这样的字符,但是都可以使用<![CDATA[ ]]>符号进行说明,将此类符号不进行解析你的可以写成这个:<![CDATA[ when min(starttime)<='12:00' and max(endtime)<='12:00' ]]>