Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Upgrading Hibernate to 6.1 – How to specify the equivalent of @Type(type="text")?

We’re currently using Hibernate 5.6 but are trying to upgrade to Hibernate 6.1. In one entity we have this property:

@Type(type = "text")
private String someText;

But in Hibernate 6.1, the type field in the @Type annotation is removed. Now the @Type annotation is defined like this:

@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 {};
}

Question: What’s the equivalent of @Type(type = "text") in Hibernate 6.1?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Based on Hibernate 5.0 documentation – For text BasicTypeRegistry key corresponds LONGVARCHAR Jdbc type.

And in Hibernate 6.1.5 documentation is offered the option to use @JdbcTypeCode annotation:

@JdbcTypeCode(Types.LONGVARCHAR)
private String text;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading