@InsertProvider(type = UserSqlProvider.class, method = "insertSql")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "GENERATED_KEY")
Long insert(Use user);
我使用ibatas @ InsertProvider,并希望获得long类型的primery键,但这种方法只是例外:
java.lang.Integer cannot be cast to java.lang.Long
怎么了?
答案 0 :(得分:0)
我自己发现了,就像这样:
@InsertProvider(type = UserSqlProvider.class, method = "insertSql")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "GENERATED_KEY")
void insert(Use user);
执行如下:
userMapper.insert(user);
System.out.print(user.getId());//use this get id