标签:mysql
1
2
3
4
5
6
7
|
List<FavUser> userList = favUserService.getAllUser(); for (FavUser favUser : userList){ SysMessage sysMessage = new SysMessage(); ... sysMessage.setReceiveUserId(favUser.getUserId()); sysMessageService.addSysMessage(sysMessage); } |
1
2
3
4
5
6
7
|
List<Integer> userIdsList = favUserService.getAllUserIds(); for (Integer userId : userIdsList ){ SysMessage sysMessage = new SysMessage(); ... sysMessage.setReceiveUserId(userId); sysMessageService.addSysMessage(sysMessage); } |
1
2
3
4
5
6
7
8
9
|
< insert id= "addBatchSysMessage" parameterType= "com.favccxx.favsoft.SysMessage" > insert into sys_message (MESSAGE_TITLE, MESSAGE_CONTENT, MESSAGE_STATUS, RECEIVE_USER_ID, RECEIVE_TIME, CREATE_TIME ) values <foreach collection= "list" item= "item" index = "index" separator= "," > ( #{item.messageTitle,jdbcType= VARCHAR },#{item.messageContent,jdbcType= VARCHAR }, #{item.messageStatus,jdbcType= CHAR }, #{item.receiveUserId,jdbcType= INTEGER },#{item.receiveTime,jdbcType= TIMESTAMP }, #{item.createTime,jdbcType= TIMESTAMP } ) </foreach> </ insert > |
1
2
3
4
5
6
7
8
|
List<FavUser> userList = favUserService.getAllUser(); List<SysMessage> dataList = new ArrayList<SysMessage>(); for (FavUser favUser : userList){ sysMessage.setReceiveUserId(favUser.getUserId()); dataList.add(sysMessage); } List<SysMessage> subList = dataList.subList( 0 , 1000 ); sysMessageService.addBatchSysMessage(subList); |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
< insert id= "addAllSysMessage" parameterType= "com.favccxx.favsoft.SysMessage" > insert into sys_message ( MESSAGE_TITLE, MESSAGE_CONTENT, MESSAGE_STATUS, RECEIVE_USER_ID, RECEIVE_TIME, CREATE_USER_ID, CREATE_TIME ) select a.MESSAGE_TITLE as MESSAGE_TITLE, a.MESSAGE_CONTENT as MESSAGE_CONTENT, 0 as MESSAGE_STATUS, b.user_id AS RECEIVE_USER_ID, now() as RECEIVE_TIME, now() as CREATE_TIME from sys_message_send_info a, ( select user_id FROM auth_user ) b where sendInfoId=#{sendInfoId} </ insert > |
1
|
int insertCount = sysMessageService.addAllSysMessage(sendInfoId); |
标签:mysql
原文地址:http://blog.csdn.net/androidmylove/article/details/41802457