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

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

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

瀏覽:193日期: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
相關文章:
主站蜘蛛池模板: 久久黄色视屏 | 九九99国产精品视频 | 国产电影网| 日本精品久久久久中文字幕 1 | 国产青草视频免费观看97 | 久久婷婷五综合一区二区 | 欧美一区二区三区免费看 | 久久草网站 | 九九免费精品视频在这里 | 看黄视频在线观看 | 国产伦精品一区二区三区网站 | 国产真实伦偷精品 | 国产精品第2页 | 尤物在线观看网站 | 国产精品视频在线播放 | 日韩国产片 | 1024在线视频精品免费播放 | 在线日韩不卡 | 欧美综合图片一区二区三区 | 亚洲欧美日韩色 | 亚洲第一成年人网站 | 欧美成人精品第一区首页 | 欧美一区二区三区久久综合 | 777免费视频 | 国产成人精品久久一区二区三区 | 日韩欧美一级毛片在线 | 久久精品国产69国产精品亚洲 | 久久成人国产精品免费 | 精品三级网站 | 午夜精品视频在线看 | 国产午夜视频在线 | 美国特级片 | 亚洲欧美日韩国产专区一区 | 亚洲精品 欧美 | 国产成人一区二区精品非洲 | 国产美女视频做爰 | 国产一区91 | 国产精品1区 | 宅男在线永久免费观看99 | 精品亚洲视频在线 | 久久婷婷国产综合精品青草 |