Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any alternatives to PostgreSQL95Dialect on upgrade to Spring boot 3.0.0 above

Is there any alternatives to PostgreSQL95Dialect on upgrade to Spring boot 3.0.0 above. Am upgrading the application to Spring boot 3.0.2 version.But I see PostgreSQL95Dialect is deprecated .What is the alternative for PostgreSQL95Dialect and registerHibernateType?

 class CustomPostgreSQLDialect extends PostgreSQL95Dialect {

    public CustomPostgreSQLDialect() {
        super();
        registerHibernateType(Types.OTHER, StringArrayType.class.getName());
        registerHibernateType(Types.OTHER, IntArrayType.class.getName());
        registerHibernateType(Types.OTHER, JsonStringType.class.getName());
        registerHibernateType(Types.OTHER, JsonBinaryType.class.getName());
        registerHibernateType(Types.OTHER, JsonNodeBinaryType.class.getName());
        registerHibernateType(Types.OTHER, JsonNodeStringType.class.getName());
    }
}

Is there any alternatives to PostgreSQL95Dialect on upgrade to Spring boot 3.0.0 above. Am upgrading the application to Spring boot 3.0.2 version.But I see PostgreSQL95Dialect is deprecated .What is the alternative for PostgreSQL95Dialect and registerHibernateType?

 class CustomPostgreSQLDialect extends PostgreSQL95Dialect {

    public CustomPostgreSQLDialect() {
        super();
        registerHibernateType(Types.OTHER, StringArrayType.class.getName());
        registerHibernateType(Types.OTHER, IntArrayType.class.getName());
        registerHibernateType(Types.OTHER, JsonStringType.class.getName());
        registerHibernateType(Types.OTHER, JsonBinaryType.class.getName());
        registerHibernateType(Types.OTHER, JsonNodeBinaryType.class.getName());
        registerHibernateType(Types.OTHER, JsonNodeStringType.class.getName());
    }
}
like image 524
Vamshi Barana Avatar asked Jan 26 '26 03:01

Vamshi Barana


1 Answers

In Hibernate 6 you do not need to explicitly specify the dialect, and you should let Hibernate choose the dialect for you.

From the migration guide:

As of Hibernate 6.0, dialects can detect and adapt to the version of the database in use and its spatial capabilities.

On the other hand, to define a custom dialect for PostgreSQL you should simply extend PostgreSQLDialect, but then you do need to explicitly specify it.

Types may be registered by overriding contributeTypes().

However, a better approach is probably to use a TypeContributor, instead of a custom dialect.

like image 197
Gavin King Avatar answered Jan 28 '26 17:01

Gavin King