将 Hibernate 升级到 6.1 - 如何指定 @Type(type="text") 的等效项?

Joh*_*han 6 java hibernate

我们当前使用 Hibernate 5.6,但正在尝试升级到 Hibernate 6.1。在一个实体中,我们具有以下属性:

@Type(type = "text")
private String someText;
Run Code Online (Sandbox Code Playgroud)

但在Hibernate 6.1中,注释type中的字段@Type被删除了。现在@Type注释的定义如下:

@java.lang.annotation.Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface Type {

    /**
     * The implementation class which implements {@link UserType}.
     */
    Class<? extends UserType<?>> value();

    /**
     * Parameters to be injected into the custom type after it is
     * instantiated. The {@link UserType} implementation must implement
     * {@link org.hibernate.usertype.ParameterizedType} to receive the
     * parameters.
     */
    Parameter[] parameters() default {};
}
Run Code Online (Sandbox Code Playgroud)

@Type(type = "text")问题: Hibernate 6.1 中相当于什么?

Geo*_*vov 6

基于Hibernate 5.0 文档- 对于textBasicTypeRegistry 键对应于LONGVARCHARJdbc 类型。

在Hibernate 6.1.5 文档中提供了使用注释的选项@JdbcTypeCode:

@JdbcTypeCode(Types.LONGVARCHAR)
private String text;
Run Code Online (Sandbox Code Playgroud)