主键生成策略必须使用 INPUT
支持父类定义 @KeySequence
子类继承使用
支持主键类型指定(3.3.0 开始自动识别主键类型)
内置支持:
DB2KeyGenerator
H2KeyGenerator
KingbaseKeyGenerator
OracleKeyGenerator
PostgreKeyGenerator
如果内置支持不满足你的需求,可实现 IKeyGenerator
接口来进行扩展.
举个例子:
@KeySequence(value = "SEQ_ORACLE_STRING_KEY", clazz = String.class)
public class YourEntity {
@TableId(value = "ID_STR", type = IdType.INPUT)
private String idStr;
}
@Bean
public IKeyGenerator keyGenerator() {
return new H2KeyGenerator();
}
@Bean
public MybatisPlusPropertiesCustomizer plusPropertiesCustomizer() {
return plusProperties -> plusProperties.getGlobalConfig().getDbConfig().setKeyGenerator(new H2KeyGenerator());
}
<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;
}
类型处理器,用于JavaType与JdbcType之间的转换,用于PreparedStatement设置参数值和从ResultSet或CallableStatement中取...
TenantLineInnerInterceptor示例工程:mybatis-plus-sample-tenant属性介绍属性名类型默认值描述tenantLineHandlerTenantLin...
鉴别器discriminator javaType="int" column="draft"case value="1" resultType="DraftPost"//discriminator有时候,一个数据库...
标准查询Hibernate 提供了操纵对象和相应的 RDBMS 表中可用的数据的替代方法。一种方法是标准的 API,它允许你建立一个标准的可...
Spring 静态页面例子下面的例子说明了如何使用 Spring MVC 框架来编写一个简单的基于 web 的应用程序,它可以在 mvc:resources ...