第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Mybatis插入mysql數(shù)據(jù)庫返回自增主鍵的問題?

Mybatis插入mysql數(shù)據(jù)庫返回自增主鍵的問題?

躍然一笑 2019-03-01 11:06:53
在mapper.xml文件配置如下: <mapper namespace="com.uiyllong.cims.dao.QuestMapper"> <resultMap type="com.uiyllong.cims.model.Selecter" id="resultSel"> <id column="selp_id" property="selpId" /> <result column="oid" jdbcType="INTEGER" property="oid" /> <result column="content" jdbcType="VARCHAR" property="content" /> <result column="selseq" jdbcType="INTEGER" property="selseq" /> </resultMap> <resultMap id="BaseResultMap" type="com.uiyllong.cims.model.Quest"> <id column="qp_id" jdbcType="INTEGER" property="qpId" /> <result column="q_content" jdbcType="VARCHAR" property="content" /> <result column="qtype" jdbcType="INTEGER" property="qtype" /> <result column="seq" jdbcType="INTEGER" property="seq" /> <result column="s_oid" jdbcType="INTEGER" property="sOid" /> <collection property="selecters" ofType="com.uiyllong.cims.model.Selecter" column="qseq_id" resultMap="resultSel"></collection> </resultMap> <!-- 插入問題 --> <insert id="insertSelective" parameterType="com.uiyllong.cims.model.Quest" useGeneratedKeys="true" keyProperty="qpId"> insert into quest_t <trim prefix="(" suffix=")" suffixOverrides=","> <if test="qpId != null"> qp_id, </if> <if test="content != null"> q_content, </if> <if test="qtype != null"> qtype, </if> <if test="seq != null"> seq, </if> <if test="sOid != null"> s_oid, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="qpId != null"> #{qpId,jdbcType=INTEGER}, </if> <if test="content != null"> #{content,jdbcType=VARCHAR}, </if> <if test="qtype != null"> #{qtype,jdbcType=INTEGER}, </if> <if test="seq != null"> #{seq,jdbcType=INTEGER}, </if> <if test="sOid != null"> #{sOid,jdbcType=INTEGER}, </if> </trim> </insert> 然后控制器調(diào)用后返回的居然一直是1 ,并沒有實現(xiàn)返回主鍵 去網(wǎng)上找了一下 都是這樣加了兩個屬性而已useGeneratedKeys="true" keyProperty="qpId"
查看完整描述

2 回答

?
夢里花落0921

TA貢獻(xiàn)1772條經(jīng)驗 獲得超6個贊

你可能理解錯了,mybatis返回主鍵并不是通過返回值的形式,而是通過set到實體的id上。你可以輸出Quest對象的qpId值,查看自增主鍵。

查看完整回答
反對 回復(fù) 2019-03-01
?
叮當(dāng)貓咪

TA貢獻(xiàn)1776條經(jīng)驗 獲得超12個贊

那你數(shù)據(jù)庫對應(yīng)的表本身有沒有設(shè)置主鍵自增呢?或者支不支持?

查看完整回答
反對 回復(fù) 2019-03-01
  • 2 回答
  • 0 關(guān)注
  • 458 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號