TeamInfo teamInfo = new TeamInfo();
teamInfo.setTeamName(context.getTeamName());
teamInfo.setSource(context.getSource());
teamInfo.setCreateDatetime(new Date());
teamInfo.setUpdateDatetime(new Date());
teamInfo.setDelFlag(CommonConstant.DEL_FLAG_NODEL);
teamInfoMapper.insert(teamInfo);
Long id = teamInfo.getId();
System.out.println("id===" + id);
这样 直接 getId 可以拿到当前的Id
方法二INSERT INTO team_info (team_name, `source`, create_datetime, update_datetime, del_flag) VALUES ('大仙集团', '大仙集团', '2022-06-01 11:32:24', '2022-06-01 11:32:24', '0') select LAST_INSERT_ID()
在 新增语句中 加入 其中 keyProperty 是 表 中id 在实体类对应的属性;
order 是在 insert 之前执行 还是之后,一般是之后
对应的Java中
TeamInfo teamInfo = new TeamInfo();
Long newId = teamInfoMapper.insertDemo(teamInfo);
System.out.println("newId===" + teamInfo.getId());
必须传入 实体对象,使用 teamInfo.getId() 获取id;
方法三:INSERT INTO team_info (team_name, `source`, create_datetime, update_datetime, del_flag) VALUES ('大仙集团', '大仙集团', '2022-06-01 11:32:24', '2022-06-01 11:32:24', '0')
其中 keyProperty 是 表 中id 在实体类对应的属性;
对应的Java中
TeamInfo teamInfo = new TeamInfo();
Long newId = teamInfoMapper.insertDemo(teamInfo);
System.out.println("newId===" + teamInfo.getId());
必须传入 实体对象,使用 teamInfo.getId() 获取id;



