Reputation: 21
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());
}
}
Upvotes: 1
Views: 4169
Reputation: 4293
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.
Upvotes: 4