亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

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

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

瀏覽:187日期: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
相關文章:
主站蜘蛛池模板: 撸大师视频在线观看 | 麻豆精品视频在线原创 | 五月婷婷综合在线 | 国产成人小视频在线观看 | 亚洲一级毛片在线观 | 国产精品123区| 青青国产成人久久91 | 九九九精品在线观看 | 91国视频在线观看 | 日韩一级在线观看 | 成人αv在线视频高清 | 欧美亚洲国产精品久久第一页 | a国产精品 | 亚洲网站在线观看 | 一级毛片在线直接观看 | 噜噜噜在线视频 | 免费三片在线观看网站 | 91国语精品自产拍在线观看性色 | 精品欧美日韩一区二区 | 国产又色又爽又黄又刺激18 | 一木道一二三区精品 | 欧美毛片一级的免费的 | 国产精品人成人免费国产 | 99热国产这里只有精品9九 | 91视频老司机 | 欧美日韩亚洲精品一区 | 人妖欧美一区二区三区四区 | 亚洲精品久久成人福利 | 亚洲第一综合网站 | 日日干天天爽 | 色琪琪久久se色 | 国产在线日韩 | 日韩视频在线观看中字 | 国产ssss在线观看极品 | 国产伦理播放一区二区 | 片成年免费观看网站黄 | 成人激情视频在线观看 | 免费精品美女久久久久久久久久 | 亚洲美女色在线欧洲美女 | 91视频国产高清 | 啪啪激情网 |