'Replacement for Hibernate's deprecated Type annotation?

Upon upgrading to Hibernate 5.6.0.Final, I found that org.hibernate.annotations.Type is now deprecated. I use this annotation in many of my entities, including places where I leverage Hibernate's own NumericBooleanType:

 @Type(type = "org.hibernate.type.NumericBooleanType")
 private Boolean debug = false;

I've searched Hibernate docs (migration guides - of which the 6.0 version gives me a 404 from http://hibernate.org/orm/documentation/6.0/), Javadocs, forums, and the web to find a replacement, to no avail.

Does anyone know what I can do now in Hibernate 5.6.0 to prepare my code using the Type annotation for the transition to Hibernate 6?



Solution 1:[1]

Edit: the change was reverted in 5.6.3. There should no longer be any deprecation warnings.


There is nothing you can do until you upgrade to 6.0, unless sufficient people complain on this issue that they revert the change in 5.6.1 or something.

Hibernate have made the unusual decision to deprecate these annotations early, before there's any replacement.

I don't know why. The only thing it will do is make people suppress the warnings, and then forget about it when 6.0 is released and never make the change.

Solution 2:[2]

For those who are wondering what's the alternative approach with hibernate 6, you have to change this from:

@Type(type = "org.hibernate.type.NumericBooleanType")
private Boolean debug = false;

to this:

@Convert(converter = org.hibernate.type.NumericBooleanConverter.class)
private Boolean debug = false;

Refer - https://docs.jboss.org/hibernate/orm/6.0/userguide/html_single/Hibernate_User_Guide.html#basic-boolean

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Gowtham