mybatis insertUseGeneratedKeys

mybatis中的一个坑:使用

insertUseGeneratedKeys插入数据时,如果id字段不是AUTO_INCREMENT,则不会生成新的id
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);
}

 

文章来自:http://www.cnblogs.com/softidea/p/5843399.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3