
文章插圖
1.Mybatis映射文件的<select>標簽主要幫助我們完成SQL語句查詢功能 , <select>標簽它包含了很多屬性 , 下面簡單對<select>標簽的屬性做一個歸納
id:唯一指定標簽的名字resultType:查詢結構返回的數據類型 , 自動進行封裝操作parameterType:給SQL語句傳遞參數的數據類型resultMap:查詢結果返回的數據類型 , 會根據映射文件中<resultMap>來完成數據封裝parameterMap:給SQL語句傳遞參數的數據類型 , 需要和<parameterMap…/>標簽連用2.下面代碼主要說明resultMap和parameterType的用法
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.gxa.mapper.TeamMapper"><resultMap type="com.gxa.pojo.Team" id="Team"><id column="t_id" property="tid"/><result column="t_name" property="tname"/></resultMap><select id="getTeam" resultMap="Team">select * from team</select><select id="getTeamById" resultMap="Team" parameterType="java.lang.Integer">select * from team where t_id = #{tid}</select><select id="getTeamById2" resultMap="Team" parameterType="com.gxa.pojo.Team">select * from team where t_id = #{tid} and t_name = #{tname}</select></mapper>3.下面代碼主要說明resultType的用法
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.gxa.mapper.MyUserMapper"><select id="getMyUser" resultType="com.gxa.pojo.MyUser" >select * from myuser</select></mapper>
以上關于本文的內容,僅作參考!溫馨提示:如遇健康、疾病相關的問題,請您及時就醫(yī)或請專業(yè)人士給予相關指導!
「愛刨根生活網」www.malaban59.cn小編還為您精選了以下內容,希望對您有所幫助:- tp link路由器設置教程 tplinkwr842n怎么樣
- 安裝網絡打印機步驟 win10連接局域網打印機設置
- 高德地圖AR步行導航怎么打開?高德地圖3D實景步行導航設置方法 高德地圖怎么看不了街景
- 恢復出廠設置的問題 iphone恢復出廠設置會怎么樣
- outlook郵箱服務器設置 outlook無法登陸服務器
- 怎么設置網絡打印機 如何設置網絡打印機
- xp開機一鍵還原步驟 xp系統(tǒng)怎么恢復出廠設置
- 詳解performselector應用場景 performselector實現原理
- windows系統(tǒng)編碼設置 查看系統(tǒng)編碼
- ppt怎么添加頁碼 ppt怎么設置背景
