Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I replace the hibernate deprecated @TypeDef and @Type annotations by?

I've just upgraded the version I use for Hibernate to 5.6.1 and it seems it's now deprecating some Type-related annotations:

@TypeDef(name = "json", typeClass = JsonBinaryType::class)


@Type(type = "json")

I found no documentation as to what to do except that

6.0 will introduce a new series of type-safe annotations to serve the same purpose

Our quality guidelines forces us to try and solve every warning and as such I would like to replace these annotations by a non deprecated use.

like image 502
Crystark Avatar asked Nov 19 '21 14:11

Crystark


People also ask

Is @entity annotation mandatory in hibernate?

The entity class must be annotated with the Entity annotation or denoted in the XML descriptor as an entity. So, if you use annotations for mappings, @Entity is mandated by the specification and Hibernate has to adhere to it.

Is hibernate deprecated?

No, Hibernate is not deprecated.

Which of the following annotation is used for hibernate?

Hibernate Example using Annotation in Eclipse. The hibernate application can be created with annotation. There are many annotations that can be used to create hibernate application such as @Entity, @Id, @Table etc. Hibernate Annotations are based on the JPA 2 specification and supports all the features.

Which annotation does not allow Hibernate to update the contents?

So hibernate did not allow to update the entity because it is immutable. You can test also removing @Immutable annotation, in this case update will be allowed.


1 Answers

It seems there is no replacement until Hibernate 6. Type and also TypeDef was marked as deprecated to mark it as removed in version 6, but so far not replacement exists. The ideology here is that deprecated does not indicate that already a new version exists, which might be not an intuitive meaning for most developers.

This was reverted now in the current 5.6.3-Final version series.

like image 180
k_o_ Avatar answered Oct 31 '22 13:10

k_o_