当前位置: 代码迷 >> J2EE >> ibatis查询有关问题
  详细解决方案

ibatis查询有关问题

热度:38   发布时间:2016-04-22 01:47:39.0
ibatis查询问题
请问下面的代码中 select 块是怎么传参数的?
XML code
<?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 namespace="jf">  <resultMap id="OM_AREA_MapWithTranslation" class="com.eshore.itsm.dao.model.OmAreaBean" >      <result property="areaId" column="AREA_ID" />       <result property="areaName" column="AREA_NAME" nullValue="" />       <result property="areaCode" column="AREA_CODE" nullValue="" />       <result property="parntAreaId" column="PARNT_AREA_ID" />       <result property="areaDesc" column="AREA_DESC" nullValue="" />   </resultMap>      <!-- 自定义SqlMap 映射对象-->   <resultMap id="OM_AREA_MapWithTranslationVo" class="com.eshore.itsm.system.om.model.OmAreaBeanVo" >      <result property="areaId" column="AREA_ID" />       <result property="areaName" column="AREA_NAME" nullValue="" />       <result property="areaCode" column="AREA_CODE" nullValue="" />       <result property="parntAreaId" column="PARNT_AREA_ID" />       <result property="areaDesc" column="AREA_DESC" nullValue="" />       <result property="parntAreaName" column="PARNT_AREA_NAME" nullValue="" />   </resultMap>    <!-- 自定义SqlMap 映射对象-->   <resultMap id="OM_AREA_MapVo" class="com.eshore.itsm.system.om.model.OmAreaBeanVo" >      <result property="areaId" column="AREA_ID" />      <result property="areaName" column="AREA_NAME" nullValue="" />      <result property="areaCode" column="AREA_CODE" nullValue="" />      <result property="parntAreaId" column="PARNT_AREA_ID" />      <result property="areaDesc" column="AREA_DESC" nullValue="" />      <result property="parntAreaName" column="PARNT_AREA_NAME" nullValue="" />   </resultMap>    <!-- 自定义SqlMap 映射对象-->   <resultMap id="OM_AREA_MapTreeNode" class="com.eshore.sysmgr.model.TreeNodeBean" >      <result property="id" column="AREA_ID" />      <result property="name" column="AREA_NAME" nullValue="" />      <result property="childCount" column="CHILD_COUNT" nullValue="" />  </resultMap>    <select id="OM_AREA_selectWithTranslation" resultMap="OM_AREA_MapWithTranslation" >    SELECT    <isPropertyAvailable property="extraHint"><isNotEmpty property="extraHint">     /*+ $extraHint$ */   </isNotEmpty></isPropertyAvailable>      AREA_ID ,      AREA_NAME ,      AREA_CODE ,      PARNT_AREA_ID ,      AREA_DESC   FROM OM_AREA A   <dynamic prepend="WHERE">          <isPropertyAvailable property="areaId" ><isNotNull prepend="AND" property="areaId">       ( AREA_ID = #areaId:NUMERIC#)      </isNotNull></isPropertyAvailable>      <isPropertyAvailable property="areaName" ><isNotEmpty  prepend="AND" property="areaName">         ( AREA_NAME = #areaName:VARCHAR#)     </isNotEmpty></isPropertyAvailable>     <isPropertyAvailable property="areaNameLikeRange" ><isNotEmpty  prepend="AND" property="areaNameLikeRange">         ( AREA_NAME LIKE #areaNameLikeRange:VARCHAR#)     </isNotEmpty></isPropertyAvailable>        <isPropertyAvailable property="areaCode" ><isNotEmpty  prepend="AND" property="areaCode">         ( AREA_CODE = #areaCode:VARCHAR#)     </isNotEmpty></isPropertyAvailable>     <isPropertyAvailable property="areaCodeLikeRange" ><isNotEmpty  prepend="AND" property="areaCodeLikeRange">         ( AREA_CODE LIKE #areaCodeLikeRange:VARCHAR#)     </isNotEmpty></isPropertyAvailable>        <isPropertyAvailable property="parntAreaId" ><isNotNull prepend="AND" property="parntAreaId">       ( PARNT_AREA_ID = #parntAreaId:NUMERIC#)      </isNotNull></isPropertyAvailable>      <isPropertyAvailable property="areaDesc" ><isNotEmpty  prepend="AND" property="areaDesc">         ( AREA_DESC = #areaDesc:VARCHAR#)     </isNotEmpty></isPropertyAvailable>     <isPropertyAvailable property="areaDescLikeRange" ><isNotEmpty  prepend="AND" property="areaDescLikeRange">         ( AREA_DESC LIKE #areaDescLikeRange:VARCHAR#)     </isNotEmpty></isPropertyAvailable>      <isPropertyAvailable property="rownum" ><isGreaterThan compareValue="0"  prepend="AND" property="rownum">        <![CDATA[  ( ROWNUM <= #rownum#)     ]]>     </isGreaterThan></isPropertyAvailable>     <isPropertyAvailable property="extraCondition" ><isNotEmpty  prepend="AND" property="extraCondition">         ( $extraCondition$ )     </isNotEmpty></isPropertyAvailable>    </dynamic>    <isPropertyAvailable property="extraOrderColumns" ><isNotEmpty property="extraOrderColumns">         ORDER BY $extraOrderColumns$   </isNotEmpty></isPropertyAvailable>   <isPropertyAvailable property="forUpdateFlag" >    <isEqual compareValue="1"  property="forUpdateFlag">       FOR UPDATE NOWAIT    </isEqual>   </isPropertyAvailable>      </select>    <!-- for drop down list-->   <resultMap id="OM_AREA_MapForDropDownList" class="com.eshore.itsm.dao.model.OmAreaBean" >      <result property="areaId" column="AREA_ID" />      <result property="areaName" column="AREA_NAME" nullValue="" />  </resultMap>    <!-- for drop down list-->   <select id="OM_AREA_selectForDropDownList" resultMap="OM_AREA_MapForDropDownList" >    SELECT      AREA_ID ,      '['||AREA_ID||']'||AREA_NAME AS AREA_NAME   FROM OM_AREA A   WHERE AREA_ID not in (           SELECT AREA_ID FROM OM_AREA START WITH AREA_ID=#areaId:NUMERIC# CONNECT BY PRIOR AREA_ID = PARNT_AREA_ID           )   ORDER BY AREA_ID ASC        <isPropertyAvailable property="forUpdateFlag" >    <isEqual compareValue="1"  property="forUpdateFlag">       FOR UPDATE NOWAIT    </isEqual>   </isPropertyAvailable>      </select>    <!-- for drop down list-->   <select id="OM_AREA_selectAllForDropDownList" resultMap="OM_AREA_MapForDropDownList" >    SELECT      AREA_ID ,      '['||AREA_ID||']'||AREA_NAME AS AREA_NAME   FROM OM_AREA A   ORDER BY AREA_ID ASC        <isPropertyAvailable property="forUpdateFlag" >    <isEqual compareValue="1"  property="forUpdateFlag">       FOR UPDATE NOWAIT    </isEqual>   </isPropertyAvailable>      </select>      <!-- 自定义查询 -->  <select id="OM_AREA_selectWithTranslationVo" resultMap="OM_AREA_MapWithTranslationVo" >    SELECT    <isPropertyAvailable property="extraHint"><isNotEmpty property="extraHint">     /*+ $extraHint$ */   </isNotEmpty></isPropertyAvailable>      AREA_ID ,      AREA_NAME ,      AREA_CODE ,      PARNT_AREA_ID ,      AREA_DESC ,      (SELECT AREA_NAME FROM OM_AREA B WHERE B.AREA_ID = A.PARNT_AREA_ID) AS PARNT_AREA_NAME   FROM OM_AREA A   <dynamic prepend="WHERE">          <isPropertyAvailable property="areaId" ><isNotNull prepend="AND" property="areaId">       ( AREA_ID = #areaId:NUMERIC#)      </isNotNull></isPropertyAvailable>      <isPropertyAvailable property="areaName" ><isNotEmpty  prepend="AND" property="areaName">         ( AREA_NAME = #areaName:VARCHAR#)     </isNotEmpty></isPropertyAvailable>     <isPropertyAvailable property="areaNameLikeRange" ><isNotEmpty  prepend="AND" property="areaNameLikeRange">         ( AREA_NAME LIKE #areaNameLikeRange:VARCHAR#)     </isNotEmpty></isPropertyAvailable>       <isPropertyAvailable property="areaCode" ><isNotEmpty  prepend="AND" property="areaCode">         ( AREA_CODE = #areaCode:VARCHAR#)     </isNotEmpty></isPropertyAvailable>     <isPropertyAvailable property="areaCodeLikeRange" ><isNotEmpty  prepend="AND" property="areaCodeLikeRange">         ( AREA_CODE LIKE #areaCodeLikeRange:VARCHAR#)     </isNotEmpty></isPropertyAvailable>        <isPropertyAvailable property="parntAreaId" ><isNotNull prepend="AND" property="parntAreaId">       ( PARNT_AREA_ID = #parntAreaId:NUMERIC#)      </isNotNull></isPropertyAvailable>      <isPropertyAvailable property="areaDesc" ><isNotEmpty  prepend="AND" property="areaDesc">         ( AREA_DESC = #areaDesc:VARCHAR#)     </isNotEmpty></isPropertyAvailable>     <isPropertyAvailable property="areaDescLikeRange" ><isNotEmpty  prepend="AND" property="areaDescLikeRange">         ( AREA_DESC LIKE #areaDescLikeRange:VARCHAR#)     </isNotEmpty></isPropertyAvailable>      <isPropertyAvailable property="rownum" ><isGreaterThan compareValue="0"  prepend="AND" property="rownum">        <![CDATA[  ( ROWNUM <= #rownum#)     ]]>     </isGreaterThan></isPropertyAvailable>     <isPropertyAvailable property="extraCondition" ><isNotEmpty  prepend="AND" property="extraCondition">         ( $extraCondition$ )     </isNotEmpty></isPropertyAvailable>    </dynamic>    <isPropertyAvailable property="extraOrderColumns" ><isNotEmpty property="extraOrderColumns">         ORDER BY $extraOrderColumns$   </isNotEmpty></isPropertyAvailable>   <isPropertyAvailable property="forUpdateFlag" >    <isEqual compareValue="1"  property="forUpdateFlag">       FOR UPDATE NOWAIT    </isEqual>   </isPropertyAvailable>      </select>      <!-- 自定义查询 -->  <select id="OM_AREA_selectByKeyVo" resultMap="OM_AREA_MapVo" >    SELECT        AREA_ID ,          AREA_NAME ,          AREA_CODE ,          PARNT_AREA_ID ,          AREA_DESC ,           (SELECT AREA_NAME FROM OM_AREA B WHERE B.AREA_ID = A.PARNT_AREA_ID) AS PARNT_AREA_NAME   FROM OM_AREA A   WHERE AREA_ID=#parntAreaId:NUMERIC#   <isPropertyAvailable property="forUpdateFlag" >    <isEqual compareValue="1"  property="forUpdateFlag">       FOR UPDATE NOWAIT    </isEqual>   </isPropertyAvailable>        </select></sqlMap>
  相关解决方案