MTR
MTR

Reputation: 1431

org.hibernate.annotations.Entity deprecated in Hibernate 4?

I am attempting to update to Hibernate 4 and I am getting that org.hibernate.annotations.Entity is deprecated. None of the documentation however seems to indicate that this is the case. Anyone have any insight into this?

@org.hibernate.annotations.Entity(dynamicUpdate = true)

Upvotes: 43

Views: 53470

Answers (4)

tolitius
tolitius

Reputation: 22519

Yes it is deprecated in 4.0+:

Deprecate org.hibernate.annotations.Entity
Its individual attributes/values should become annotations. 
Schedule for removal in 4.1

You should use @DynamicUpdate instead

Here is a fixed JIRA talking about it.

Upvotes: 41

Gunta Vaishnavi
Gunta Vaishnavi

Reputation: 419

Use the JPA @Entity annotation instead of the Hibernate @Entity annotation. Look in your imports, it should say

    import javax.persistence.Entity;

and not

    import org.hibernate.annotations.Entity;

Upvotes: 6

adjs1157
adjs1157

Reputation: 103

From Hibernate Getting Started Guide :

The @javax.persistence.Entity annotation is used to mark a class as an entity. It functions the same as the class mapping element discussed in Section 2.3, "The mapping file". Additionally the @javax.persistence.Table annotation explicitly specifies the table name. Without this specification, the default table name would be EVENT).

Since org.hibernate.annotations.Entity has been deprecated you should use the Java EE annotation. Also, as tolitius already mentioned, for the annotation configurations of @org.hibernate.annotations.Entity, you should use the respective annotation, e.g. @DynamicUpdate.

Hope that helps.


Note: Event is the name of the class that is annotated in the example, this is why it states "default table name would be EVENT".

Upvotes: 9

Arti M
Arti M

Reputation: 21

For future purpose, please refer the deprecated API list for Hibernate 4.0. The link is as follows:- Deprecated API

Upvotes: 2

Related Questions