国产chinesehdxxxx野外,国产av无码专区亚洲av琪琪,播放男人添女人下边视频,成人国产精品一区二区免费看,chinese丰满人妻videos

MyBatis-Plus 核心功能-主鍵策略

2022-03-24 16:31 更新

提示

主鍵生成策略必須使用 ?INPUT ?

支持父類(lèi)定義 ?@KeySequence? 子類(lèi)繼承使用

支持主鍵類(lèi)型指定(3.3.0 開(kāi)始自動(dòng)識(shí)別主鍵類(lèi)型)

內(nèi)置支持:

  • ?DB2KeyGenerator ?
  • ?H2KeyGenerator ?
  • ?KingbaseKeyGenerator ?
  • ?OracleKeyGenerator ?
  • ?PostgreKeyGenerator ?

如果內(nèi)置支持不滿(mǎn)足你的需求,可實(shí)現(xiàn) ?IKeyGenerator?接口來(lái)進(jìn)行擴(kuò)展.

舉個(gè)例子:

@KeySequence(value = "SEQ_ORACLE_STRING_KEY", clazz = String.class)
public class YourEntity {

    @TableId(value = "ID_STR", type = IdType.INPUT)
    private String idStr;

}

Spring-Boot

方式一:使用配置類(lèi)

@Bean
public IKeyGenerator keyGenerator() {
    return new H2KeyGenerator();
}

方式二:通過(guò) MybatisPlusPropertiesCustomizer 自定義

@Bean
public MybatisPlusPropertiesCustomizer plusPropertiesCustomizer() {
    return plusProperties -> plusProperties.getGlobalConfig().getDbConfig().setKeyGenerator(new H2KeyGenerator());
}

Spring

方式一: XML 配置

<bean id="globalConfig" class="com.baomidou.mybatisplus.core.config.GlobalConfig">
   <property name="dbConfig" ref="dbConfig"/>
</bean>

<bean id="dbConfig" class="com.baomidou.mybatisplus.core.config.GlobalConfig.DbConfig">
   <property name="keyGenerator" ref="keyGenerator"/>
</bean>

<bean id="keyGenerator" class="com.baomidou.mybatisplus.extension.incrementer.H2KeyGenerator"/>

方式二:注解配置

@Bean
public GlobalConfig globalConfig() {
	GlobalConfig conf = new GlobalConfig();
	conf.setDbConfig(new GlobalConfig.DbConfig().setKeyGenerator(new H2KeyGenerator()));
	return conf;
}


以上內(nèi)容是否對(duì)您有幫助:
在線(xiàn)筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)