时间:2021-07-01 10:21:17 帮助过:49人阅读
注意:插入的时候id可以省略,但masterId必须对应的上AddMaster这个JavaBean的masterId属性。
表结构如下:
MySQL [mcloud]> desc t_mc_store_group_master;
+-------------+--------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+-------------------+-----------------------------+
| id | bigint(16) | NO | PRI | NULL | auto_increment |
| u_id | varchar(128) | NO | MUL | NULL | |
| u_name | varchar(128) | YES | | NULL | |
| dept_name | varchar(128) | YES | | NULL | |
| create_time | timestamp | YES | | CURRENT_TIMESTAMP | |
| update_time | timestamp | YES | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+-------------+--------------+------+-----+-------------------+-----------------------------+
<insert id="addMaster" parameterType="com.xxx.smart.group.model.AddMaster" > INSERT INTO t_mc_store_group_master (id,u_id,u_name,dept_name) VALUES (#{masterId},#{uid},#{uName},#{deptName}) <selectKey resultType="Integer" order="AFTER" keyProperty="masterId"> SELECT LAST_INSERT_ID() AS masterId </selectKey> </insert>
本文出自 “Curiosity” 博客,请务必保留此出处http://flash09.blog.51cto.com/8831225/1909761
Mybatis 项目开发实际常用SQL笔记总结
标签:java、mybatis