插入sql返回主键id】的更多相关文章

<insert id="insertSelective" parameterType="com.xxx.model.XDetail" useGeneratedKeys="true" keyProperty="id"> 主要依靠useGeneratedKeys="true" keyProperty="id"实现…
关于Sequence主键的数据库来说,如: <insert id="add" parameterType="vo.Category"> <selectKey resultType="java.lang.Short" order="BEFORE" keyProperty="id"> SELECT SEQ_TEST.NEXTVAL FROM DUAL </selectKey>…
<insert id="insertCharge" parameterType="com.bb.bean.Rechargerecord"> <selectKey keyProperty="id" resultType="java.lang.Integer" order="AFTER"> select LAST_INSERT_ID() </selectKey> INSERT…
<!-- 插入数据:返回记录的id值 --> <insert id="insertOneTest" parameterType="org.chench.test.mybatis.model.Test" useGeneratedKeys="true" keyProperty="id" keyColumn="id"> insert into test(name,descr,url,cre…
具体xml中sql是这样写,但是要注意SQ_USER.Nextval,SQ_USER是序列,你要替换下自己要进行操作的表的序列,不知道序列的话,可以sql查找下,select * from user_sequences查找全部序列,找到该表单序列名称,或者模糊查询表名select * from user_sequences where SEQUENCE_NAME LIKE '%USER%';,找到序列名称替换SQ_USER即可 <insert id="insertSelective&quo…
<insert id="add" parameterType="com.dsa.core.base.model.ProductSync">        insert into tm_sync_product(            <if test="productId!=null">product_id,</if>            <if test="mainLimit!=null&q…
需要在insert方法中添加 <insert id="insertSelective" parameterType="com.midou.ott.model.MDActivity" useGeneratedKeys="true" keyProperty="id"> 加上上面红色部分,keyProperty中的id,是MDActivity对象的中的Id 使用时直接从MDActivity对象中获取到ID…
我们都知道Mybatis在插入单条数据的时候有两种方式返回自增主键: 1.对于支持生成自增主键的数据库:增加 useGenerateKeys和keyProperty ,<insert>标签属性. 2.不支持生成自增主键的数据库:使用<selectKey>. 但是怎么对批量插入数据返回自增主键的解决方式网上看到的还是比较少,至少百度的结果比较少. Mybatis官网资料提供如下: First, if your database supports auto-generated key…
以前只用过在insert完以后利用select @@IDENTITY返回主键ID,最近在做微信公众平台,遇到一个需求是在帮绑定万微信openid后自动完成登陆,这就需要update以后返回主键ID,查了一些资料找到了output这一解决方案. update [SmartPromoter] set [Name]='aaaaaaaa' output DELETED.[ID] where [Mobile]='18669698888' 经测试,insert.update.delete都可以返回主键ID…
有时,我们需要往一张表插入一条记录,同时返回主键ID值. 假定主键ID的值都是通过对应表的SEQUENCE来获得,然后进行ID赋值 这里有几种情况需要注意: 1)如果建表语句含有主键ID的触发器,通过触发器来实现主键ID的自增,实现方式如下: INSERT INTO GP_MONTH_BILL ( MONTH, BONUS_VALUE, CUR_WAY, CUR_TIME, STATUS, IS_USE, CREATE_TIME) VALUES ( CUR_MONTH, CUR_BONUS_VA…