在MyBatis中<insert id="save" useGeneratedKeys="true" keyProperty="id" keyColumn="id"> 返回id 但是值得注意的是,如果你在java中使用 int id= mapper.save() 去接收时,id 返回的会是 1
需要得到数据库中你保存数据的id ,需使用bean 去接收,如:
User user = mapper.save();
int id = user.getId();
在MyBatis中<insert id="save" useGeneratedKeys="true" keyProperty="id" keyColumn="id"> 返回id 但是值得注意的是,如果你在java中使用 int id= mapper.save() 去接收时,id 返回的会是 1
需要得到数据库中你保存数据的id ,需使用bean 去接收,如:
User user = mapper.save();
int id = user.getId();