package tk.mybatis.mapper.common.special;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import tk.mybatis.mapper.provider.SpecialProvider;
public interface InsertUseGeneratedKeysMapper<T> {
@Options(
useGeneratedKeys = true,
keyProperty = "id"
)
@InsertProvider(
type = SpecialProvider.class,
method = "dynamicSQL"
)
int insertUseGeneratedKeys(T var1);
}
1、使用 insertUseGeneratedKeys插入數據時,如果id字段不是AUTO_INCREMENT,則不會生成新的id
2、建表的時候主鍵名定義為id,否則不會返回主鍵
