`

ibatis sqlmap配置实例

 
阅读更多

 

 

ibatis sqlmap配置实例

 

 

 

<?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="Student">

 

<typeAlias alias="student" type="com.su.framwork.demo.Student" />

<resultMap id="studentResultMap" class="com.su.framwork.demo.Student">

<result property="studentId" column="studentId" />

<result property="name" column="name" javaType="java.lang.String" jdbcType="Varchar"/>

<result property="password" column="password" />

<result property="birthday" column="birthday" />

<result property="email" column="email" />

<result property="gender" column="gender" />

</resultMap>

<parameterMap id="studentParameterMap" class="java.util.HashMap" >

<parameter property="studentId" jdbcType="VARCHAR" javaType="java.lang.String" mode="INOUT"/>

<parameter property="name" jdbcType="VARCHAR" javaType="java.lang.String" mode="INOUT"/>

</parameterMap>

<insert id="insert" parameterClass="student">

<![CDATA[

insert into student (name,password,birthday,email,gender) values(#name#,#password#,#birthday#,#email#,#gender#)

]]>

</insert>

 

<update id="update" parameterClass="student">

<![CDATA[

update student set name=#name#, password=#password#,birthday=#birthday#,email=#email#,gender=#gender# where studentId = #studentId#

]]>

</update>

 

<delete id="deleteById" parameterClass="java.lang.String">

<![CDATA[

delete from student where studentId = #studentId# 

]]>

</delete>

 

<delete id="deleteByCriteria">

<![CDATA[

delete from student where studentId = #studentId# 

]]>

</delete>

<procedure id="proc" parameterMap="studentParameterMap">

{call swap_email_address (?,?)}

</procedure>

 

 

<select id="queryAll" resultMap="studentResultMap">

<![CDATA[

select * from student

]]>

</select>

 

<select id="queryById" parameterClass="java.lang.String"

resultClass="student">

<![CDATA[

select * from student where studentId=#studentId#

]]>

</select>

 

<select id="queryCount" parameterClass="student">

select count(1) from student

<dynamic prepend="WHERE">

<isNotEmpty prepend="AND" property="name">

name like #name#

</isNotEmpty>

<isNotEmpty prepend="AND" property="password">

<![CDATA[ password = #password# ]]>

</isNotEmpty>

<isNotEmpty prepend="and" property="birthday">

<![CDATA[birthday>=to_date(#birthday#,'YYYY-MM-DD hh:mi:ss')]]>

</isNotEmpty>

</dynamic>

</select>

 

 

<select id="query"  parameterClass="student">

select * from student

<dynamic prepend="WHERE">

<isNotEmpty prepend="AND" property="name">

name like #name#

</isNotEmpty>

<isNotEmpty prepend="AND" property="password">

<![CDATA[ password = #password# ]]>

</isNotEmpty>

<isNotEmpty prepend="and" property="birthday">

<![CDATA[birthday>=to_date(#birthday#,'YYYY-MM-DD hh:mi:ss')]]>

</isNotEmpty>

</dynamic>

</select>

</sqlMap>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics