mybatics 获取insert自增id的两种方法
2013-08-17 20:25
295 查看
一:在map.xml文件中增加:useGeneratedKeys="true" keyProperty="id"
例子:<insert id="insert" parameterType="com.target.infrastructure.db.model.Document" useGeneratedKeys="true" keyProperty="id">
二:在map.xml文件中增加:
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID() AS ID
</selectKey>
例子:
<insert id="insert" parameterType="cn.***.beans.LogObject" >
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID() AS ID
</selectKey>
INSERT INTO TableName ...
参考:
http://stackoverflow.com/questions/7205365/how-to-return-key-after-insert-using-mybatis-when-the-id-uuid-as-is-stored-as-bi
/article/7444320.html
例子:<insert id="insert" parameterType="com.target.infrastructure.db.model.Document" useGeneratedKeys="true" keyProperty="id">
二:在map.xml文件中增加:
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID() AS ID
</selectKey>
例子:
<insert id="insert" parameterType="cn.***.beans.LogObject" >
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID() AS ID
</selectKey>
INSERT INTO TableName ...
参考:
http://stackoverflow.com/questions/7205365/how-to-return-key-after-insert-using-mybatis-when-the-id-uuid-as-is-stored-as-bi
/article/7444320.html
相关文章推荐
- 【转载】在mysql中获取insert插入数据的id的方法SELECT LAST_INSERT_ID();
- 微信网页开发之获取用户unionID的两种方法--基于微信的多点登录用户识别
- 两种方法获取MyBatis刚刚插入的id
- Android中由文件名获取文件Id的两种方法
- android--由文件名获取文件Id的两种方法
- Android中由文件名获取文件Id的两种方法
- 微信网页开发之获取用户unionID的两种方法--基于微信的多点登录用户识别
- hibernate实现分表后获取insert自增ID方法。
- mybatis的insert语句获取自增id的方法(mySQL)
- Sqlite 清空表中所有数据 并重置自增长数据 以及获取last_insert_id的方法
- android--由文件名获取文件Id的两种方法
- 两种方法获取MyBatis刚刚插入的id
- 获取mac地址的两种方法
- 动态获取程序的版本名称的方法以及dialog的简单用法以及两种上下文的区别
- Javascript下获取对象引用的两种方法之getElementsByTagName
- 07-session实现简易购物车2(获取sessionid方法SID)
- android获取文件getMimeType的两种方法
- oracle数据库insert后获取insert数据的自增id值
- 根据日期获取星期几的两种方法
- 【opencv】获取图片某点像素值的两种方法