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

前端 未结 4 1504
执笔经年
执笔经年 2020-12-05 13:43

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

相关标签:
4条回答
  • 2020-12-05 13:53

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

    0 讨论(0)
  • 2020-12-05 14:01

    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;
    
    0 讨论(0)
  • 2020-12-05 14:02

    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.

    0 讨论(0)
  • 2020-12-05 14:05

    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".

    0 讨论(0)
提交回复
热议问题