<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="User">
<typeAlias alias="userBean" type="com.huawei.test.manager.UserBean" />
<!-- 插入数据 -->
<insert id="storeUserInfo" parameterClass="userBean">
INSERT INTO DBUSER
VALUES(DBUSERSEQ.NEXTVAL,#username#,#password#,#sex#,#age#,#address#)
</insert>
<!-- 查询数据 -->
<resultMap id="selectResult" class="userBean">
<result property="id" column="id" />
<result property="username" column="username" />
<result property="password" column="password" />
<result property="sex" column="sex" />
<result property="age" column="age" />
<result property="address" column="address" />
</resultMap>
<!-- 查询单条记录 -->
<select id="getUserInfo" parameterClass="java.lang.String"
resultMap="selectResult">
SELECT ID,USERNAME,PASSWORD,SEX,AGE,ADDRESS FROM DBUSER WHERE
ID=#id#
</select>
<!-- 调用存储过程 -->
<parameterMap id="P_INSERT_PARAM" class="java.util.HashMap">
<parameter property="v_username" javaType="java.lang.String"
jdbcType="VARCHAR" mode="IN" />
<parameter property="v_password" javaType="java.lang.String"
jdbcType="VARCHAR" mode="IN" />
<parameter property="v_sex" javaType="java.lang.String"
jdbcType="VARCHAR" mode="IN" />
<parameter property="v_age" javaType="java.lang.Integer"
jdbcType="INTEGER" mode="IN" />
<parameter property="v_address" javaType="java.lang.String"
jdbcType="VARCHAR" mode="IN" />
</parameterMap>
<procedure id="testProcedure" parameterMap="P_INSERT_PARAM">
{CALL TESTPRO(?,?,?,?,?)}
</procedure>
<!-- 查询列表 -->
<select id="getUserList" resultMap="selectResult">
SELECT ID,USERNAME,PASSWORD,SEX,AGE,ADDRESS FROM DBUSER ORDER BY ID
</select>
<!-- 删除 -->
<delete id="deleteUser" parameterClass="java.lang.String">
delete from dbuser where id=#id#
</delete>
<!-- 更新 -->
<update id="updateUser" parameterClass="userBean">
UPDATE DBUSER SET
USERNAME=#username#,PASSWORD=#password#,SEX=#sex#,AGE=#age#,ADDRESS=#address#
WHERE ID=#id#
</update>
</sqlMap>
ibatis
最新推荐文章于 2024-11-13 20:43:20 发布