[英]R2dbc enum type support (mssql, oracle, mariadb, ect)
With R2dbc postgresql, we can easily map java enum type with database enum type:使用 R2dbc postgresql,我们可以轻松地将 map java 枚举类型与数据库枚举类型:
@Bean
public ConnectionFactory pgConnectionFactory() {
return new PostgresqlConnectionFactory(
PostgresqlConnectionConfiguration.builder()
.host("localhost")
.database("test")
.username("user")
.password("password")
.codecRegistrar(EnumCodec.builder().withEnum("status", Status.class).build())
.build()
);
}
Now I want to apply this mapping to: mariadb, mssql, oracle and so on.现在我想将此映射应用于:mariadb、mssql、oracle 等。 Do these dbmss have the same functionality?
这些 dbmss 是否具有相同的功能?
MariaDB supports the same enum type as MySQL, which is just a fancy check constraint on a VARCHAR
column, not an actual enum type. MariaDB 支持与 MySQL 相同的枚举类型,这只是对
VARCHAR
列的奇特检查约束,而不是实际的枚举类型。
If you want to implement database agnostic enum types across all those dialects, I recommend you use CHECK
constraints instead of enums.如果您想在所有这些方言中实现与数据库无关的枚举类型,我建议您使用
CHECK
约束而不是枚举。
Note that hopefully, a future version of the r2dbc-postgresql driver will support enum types out of the box: https://github.com/pgjdbc/r2dbc-postgresql/issues/429请注意,希望 r2dbc-postgresql 驱动程序的未来版本将支持开箱即用的枚举类型: https://github.com/pgjdbc/r2dbc-postgresql/issues/429
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.