mybatis 获取自增id

    在开发中碰到用户注册的功能需要用到用户ID,但是用户ID是数据库自增生成的,使用下面的注解mybatis的insert语句可以解决:

@InsertProvider(type = UserSqlProvider.class, method = "insert")
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(User user);

猜你喜欢

转载自my.oschina.net/u/182501/blog/1633403