亚洲免费在线视频-亚洲啊v-久久免费精品视频-国产精品va-看片地址-成人在线视频网

您的位置:首頁技術文章
文章詳情頁

java - Mybatis插入mysql數據庫返回自增主鍵的問題?

瀏覽:205日期:2024-04-01 13:32:51

問題描述

在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 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 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>

然后控制器調用后返回的居然一直是1 ,并沒有實現返回主鍵去網上找了一下 都是這樣加了兩個屬性而已useGeneratedKeys='true' keyProperty='qpId'

問題解答

回答1:

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

回答2:

那你數據庫對應的表本身有沒有設置主鍵自增呢?或者支不支持?

標簽: java
相關文章:
主站蜘蛛池模板: 手机看片日韩日韩韩 | 国产美女做爰免费视频网址 | 免费国产精品视频 | 亚洲小视频网站 | 欧美日产国产亚洲综合图区一 | 国产精品11p | 国产高清视频在线播放 | 一本久道久久综合中文字幕 | 国产性生交xxxxx免费 | 欧美一级专区免费大片野外交 | 91精品国产高清久久久久久91 | 特级毛片全部免费播放a一级 | 成 人免费va视频 | 成人久久18免费网 | 性做爰片免费视频毛片中文i | 日本特黄乱人伦片 | 成人精品区 | 在线成年人网站 | 91久久精品青青草原伊人 | 国产成人毛片 | 高跟丝袜美女一级毛片 | 在线播放亚洲美女视频网站 | 日韩毛片高清在线看 | 精品久久久久久 | 国产日韩欧美精品 | 看一级毛片 | 久久久久久久久一级毛片 | 亚洲精品一区二区四季 | 欧美日韩亚洲成色二本道三区 | 国厂自拍 | 日韩久草 | 久久久夜间小视频 | 日韩经典在线观看 | 欧美色久 | 日韩精品免费视频 | 成人18免费 | 精品欧美日韩一区二区三区 | 俄罗斯黄色一级片 | 免费一级大片 | 欧美日韩在线播放一区二区三区 | 国产精品一区二区三区久久 |