Ibatis的配置

来源:互联网 发布:用java写一个登陆界面 编辑:程序博客网 时间:2024/05/01 15:25
<?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="FLOW_LOTTERY_MANAGE">
    <!-- typeAlias -->
      <typeAlias alias="flowLotteryManage" type="com._21cn.hzflow.entity.FlowLotteryManage"/>

      <!-- resultMap -->
    <resultMap id="flowLotteryManageResult" class="flowLotteryManage">
        <result column="ID" property="id" jdbcType="DECIMAL" />
        <result column="LOTTERY_ID" property="lotteryId" jdbcType="DECIMAL" />
        <result column="USER_ID" property="userId" jdbcType="VARCHAR" />
        <result column="LOTTERY_TYPE" property="lotteryType" jdbcType="DECIMAL" />
        <result column="WEEK_NO" property="weekNo" jdbcType="DECIMAL" />
        <result column="CREATE_DATE" property="createDate" jdbcType="TIMESTAMP" />
        <result column="MODIFY_DATE" property="modifyDate" jdbcType="TIMESTAMP" />
        <result column="MEMO" property="memo" jdbcType="VARCHAR" />
    </resultMap>

    <!-- sql where -->
    <sql id="findFlowLotteryManageList_Where">
        <dynamic prepend="where">
            <isPropertyAvailable prepend="and" property="id">
                ID = #id:DECIMAL#
            </isPropertyAvailable>
            <isPropertyAvailable prepend="and" property="lotteryId">
                LOTTERY_ID = #lotteryId:DECIMAL#
            </isPropertyAvailable>
            <isPropertyAvailable prepend="and" property="userId">
                USER_ID = #userId:VARCHAR#
            </isPropertyAvailable>
            <isPropertyAvailable prepend="and" property="artistName_like">
                USER_ID like '%'||#userId:VARCHAR#||'%'
            </isPropertyAvailable>
            <isPropertyAvailable prepend="and" property="lotteryType">
                LOTTERY_TYPE = #lotteryType:DECIMAL#
            </isPropertyAvailable>
            <isPropertyAvailable prepend="and" property="weekNo">
                WEEK_NO = #weekNo:DECIMAL#
            </isPropertyAvailable>
            <isPropertyAvailable prepend="and" property="memo">
                MEMO = #memo:VARCHAR#
            </isPropertyAvailable>
            <isPropertyAvailable prepend="and" property="createDate">
            to_char(CREATE_DATE,'YYYY-MM-DD')  like '%$createDate$%'
            </isPropertyAvailable>
            <isPropertyAvailable prepend="and" property="modifyDate">
            to_char(MODIFY_DATE,'YYYY-MM-DD')  like '%$modifyTime$%'
            </isPropertyAvailable>
            <isPropertyAvailable prepend="and" property="artistName_like">
                MEMO like '%'||#memo:VARCHAR#||'%'
            </isPropertyAvailable>
            <isPropertyAvailable prepend="and" property="idList">
                ID in '('||#idList#||')'
            </isPropertyAvailable>
        </dynamic>
        <dynamic prepend="order by">
            <isNotNull prepend="," property="id_orderBy">
                ID $id_orderBy$
            </isNotNull>
            <isNotNull prepend="," property="lotteryId_orderBy">
                LOTTERY_ID $lotteryId_orderBy$
            </isNotNull>
            <isNotNull prepend="," property="userId_orderBy">
                USER_ID $userId_orderBy$
            </isNotNull>
            <isNotNull prepend="," property="lotteryType_orderBy">
                LOTTERY_TYPE $lotteryType_orderBy$
            </isNotNull>
            <isNotNull prepend="," property="weekNo_orderBy">
                WEEK_NO $weekNo_orderBy$
            </isNotNull>
            <isNotNull prepend="," property="createDate_orderBy">
                CREATE_DATE $createDate_orderBy$
            </isNotNull>
            <isNotNull prepend="," property="modifyDate_orderBy">
                MODIFY_DATE $modifyDate_orderBy$
            </isNotNull>
            <isNotNull prepend="," property="memo_orderBy">
                MEMO $memo_orderBy$
            </isNotNull>
        </dynamic>
    </sql>

    <!-- findFlowLotteryManageList -->
    <select id="findFlowLotteryManageList_Count" parameterClass="java.util.Map" resultClass="java.lang.Integer">
        select count(*) from FLOW_LOTTERY_MANAGE
        <isParameterPresent>
            <include refid="findFlowLotteryManageList_Where"/>
        </isParameterPresent>
    </select>

    <select id="findFlowLotteryManageList_Page" parameterClass="java.util.Map" resultMap="flowLotteryManageResult">
        select * from
        (
            select t.*, rownum rn from
            (
                select * from FLOW_LOTTERY_MANAGE t1
                    <isParameterPresent>
                        <include refid="findFlowLotteryManageList_Where"/>
                    </isParameterPresent>
            ) t
            <![CDATA[ where rownum <= $pagination.lastIndex$ ]]>
        )
        where rn >= $pagination.startIndex$
    </select>

    <select id="findFlowLotteryManageList" parameterClass="java.util.Map" resultMap="flowLotteryManageResult">
        select * from FLOW_LOTTERY_MANAGE
        <isParameterPresent>
            <include refid="findFlowLotteryManageList_Where"/>
        </isParameterPresent>
    </select>

    <!-- findFlowLotteryManageByPk -->
    <select id="findFlowLotteryManageByPk"  parameterClass="flowLotteryManage" resultMap="flowLotteryManageResult">
        select * from FLOW_LOTTERY_MANAGE
        where ID = #id:DECIMAL#
    </select>

    <!-- insert -->
    <insert id="insertFlowLotteryManage" parameterClass="flowLotteryManage">
        <selectKey resultClass="java.lang.Long" keyProperty="id">
        select SEQ_FLOW_LOTTERY_MANAGE.nextval from dual
        </selectKey>    
        insert into FLOW_LOTTERY_MANAGE (
            ID
            , LOTTERY_ID
            , USER_ID
            , LOTTERY_TYPE
            , WEEK_NO
            , CREATE_DATE
            , MODIFY_DATE
            , MEMO
        ) values (
            #id:DECIMAL#
            , #lotteryId:DECIMAL#
            , #userId:VARCHAR#
            , #lotteryType:DECIMAL#
            , #weekNo:DECIMAL#
            , #createDate:TIMESTAMP#
            , #modifyDate:TIMESTAMP#
            , #memo:VARCHAR#
        )
    </insert>

    <!-- update by primary key -->
    <update id="updateFlowLotteryManageByPk" parameterClass="flowLotteryManage">
        update FLOW_LOTTERY_MANAGE set
            ID = #id:DECIMAL#
            , LOTTERY_ID = #lotteryId:DECIMAL#
            , USER_ID = #userId:VARCHAR#
            , LOTTERY_TYPE = #lotteryType:DECIMAL#
            , WEEK_NO = #weekNo:DECIMAL#
            , CREATE_DATE = #createDate:TIMESTAMP#
            , MODIFY_DATE = #modifyDate:TIMESTAMP#
            , MEMO = #memo:VARCHAR#
        where ID = #id:DECIMAL#
    </update>

    <!-- delete by primary key -->
    <delete id="deleteFlowLotteryManageByPk" parameterClass="flowLotteryManage">
        delete from FLOW_LOTTERY_MANAGE
        where ID = #id:DECIMAL#
    </delete>

</sqlMap>


<spring中的配置>

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
        "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
    <settings
        cacheModelsEnabled="false"
        enhancementEnabled="true"
        lazyLoadingEnabled="true"
        errorTracingEnabled="true"
        maxSessions="64"
        maxTransactions="8"
        maxRequests="128"
    />

    <sqlMap resource="com/_21cn/hzflow/dao/ibatis/sqlmap/FLOW_LOTTERY_MANAGE_SqlMap.xml" />
    
 

</sqlMapConfig>


原创粉丝点击