Mybatis插入语句useGeneratedKeys="true"的用法
<!-- 插入新的问题件 -->
<!-- useGeneratedKeys="true"把新增加的主键赋值到自己定义的keyProperty(id)中 -->
<insert id="insert" parameterType="jw.base.entity.WrongRecApply" useGeneratedKeys="true" keyProperty="id" >
insert into tb_wrong_rec_apply (num, cid,
`type`, `describe`, solution,
seller_tel, seller_qq, seller_email,
buyer_tel, buyer_qq, buyer_email,
submit_time, update_time, r_wrong_id,
ext1, ext2, img,state
)
values (#{num,jdbcType=VARCHAR}, #{cid,jdbcType=INTEGER},
#{type,jdbcType=VARCHAR}, #{describe,jdbcType=VARCHAR}, #{solution,jdbcType=VARCHAR},
#{sellerTel,jdbcType=VARCHAR}, #{sellerQq,jdbcType=VARCHAR}, #{sellerEmail,jdbcType=VARCHAR},
#{buyerTel,jdbcType=VARCHAR}, #{buyerQq,jdbcType=VARCHAR}, #{buyerEmail,jdbcType=VARCHAR},
#{submitTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{rWrongId,jdbcType=INTEGER},
#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{img,jdbcType=LONGVARBINARY},#{state,jdbcType=INTEGER}
)
</insert>
useGeneratedKeys 取值范围true|false 默认值是:false。 含义:设置是否使用JDBC的getGenereatedKeys方法获取主键并赋值到keyProperty设置的领域模型属性中。
Mybatis插入语句useGeneratedKeys="true"的用法的更多相关文章
- mybatis 插入语句name no find
1.可参考连接:https://www.cnblogs.com/thomas12112406/p/6217211.html 2.dao层的配置 void addUser(@Param("un ...
- mybatis 插入语句 返回自增长id方法
背景:目前有个插入语句需要获取插入记录的id 因为id是自增长的,所以要在插入后返回这个id 错误1: mapper.xml: <!-- 新增 返回自增长id--> <insert ...
- MyBatis插入语句返回主键值
插入语句xml代码: <insert id="insertUser" parameterType="com.spring.mybatis.po.User" ...
- mybatis插入语句空值没有设置jdbcType报错
Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: Error setti ...
- mybatis插入是返回主键id
<!-- 插入数据:返回记录的id值 --> <insert id="insertOneTest" parameterType="org.chench. ...
- Mybatis各语句高级用法(未完待续)
更多的语法请参考官网 http://www.mybatis.org/mybatis-3/dynamic-sql.html# 环境:MySQL5.6,jdk1.8 建议:所有的参数加上@Param re ...
- MyBatis的动态插入语句(经常报‘无效的列类型’)
最近在工作中经常遇到一个情况:通过mybatis的标签执行插入语句,当表中字段比较多的时候,需要全部插入,而有时候的需求是只插入其中几个字段,但是会报错. 原来的语句,必须把所有字段都Set值. &l ...
- mybatis <!-- useGeneratedKeys="true"把新增加的主键赋值到自己定义的keyProperty(id)中 -->
<!-- useGeneratedKeys="true"把新增加的主键赋值到自己定义的keyProperty(id)中 -->
- mybatis使用@Insert @SelectKey 执行插入语句时获得主键自增长值(转)
@Insert(" insert into table(c1,c2) " + " values (#{c1},#{c2}) ") @SelectKey(resu ...
随机推荐
- ExtJs API 下载以及部署
ExtJs API 下载方法 1.进入sencha官网:https://www.sencha.com/ 2.点击“Docs”进入文档帮助页面:http://docs.sencha.com/ 3.点击左 ...
- 利用GDB在远程开发机进行调试
由于一些环境的制约,很多同学都可能需要在开发机上进行调试,但由于开发机资源的限制,在开发机上直接进行本地的GDB环境配置就成了难题,这个时候其实我们可以利用GDB中自带的gdbserver工具就可以进 ...
- underscorejs-reduce学习
2.3 reduce 2.3.1 语法: _.reduce(list, iteratee, [memo], [context]) 2.3.2 说明: reduce方法把list中元素归结为一个单独的数 ...
- 扩展PHP内置的异常处理类
在try代码块中,需要使用throw语句抛出一个异常对象,才能跳到转到catch代码块中执行,并在catch代码块中捕获并使用这个异常类的对象.虽然在PHP中提供的内置异常处理类Exception,已 ...
- 2016-12-14jq笔记
1.在jq中声明一个数组的方法有两种: 1.var a=new Array(): 2 var b=[]; (效果一致) 2.bind()和live()的区别 3.animate的用法 4.place ...
- UART RS232 的CTS与RTS
目前较为常用的串口有9针串口(DB9)和25针串口(DB25),通信距离较近时(<12m),可以用电缆线直接连接标准RS232端口(RS422,RS485较远),若距离较远,需附加调制解调器(M ...
- android视图切换动画:ViewAnimator类及其子类
类图:
- 两台windows服务器----SVN的迁移
两台服务器,进行SVN的迁移:系统平台:windows server 2003 版本库:test源服务器:192.168.1.14目标服务器:192.168.1.12源SVN版本库的path: D:\ ...
- (转载)php反射类 ReflectionClass
(转载)http://hi.baidu.com/daihui98/item/a67dfb8213055dd75f0ec165 php反射类 ReflectionClass 什么是php反射类,可以 ...
- Word Break II——LeetCode
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each ...