Deprecated @Entity Annotation in Hibernate 4

SHARE & COMMENT :

In the earlier versions of Hibernate, we use @Entity for marking a class as persistence entity in the database. It has list of attributes to be used as the parameters. @Entity has been deprecated from the hibernate 4 and will be removed from the hibernate 5.0 release. There is a confusion in the consistency of  information provided on their websites about the removal of these annotations. However, If you are using this annotation in the earlier versions of hibernate, you have to change before planning to migrate your project to higher versions. @Entity has the following list of attributes.

  1. dynamicInsert
  2. dynamicUpdate
  3. mutable
  4. optimisticLock
  5. persister
  6. polymorphism
  7. selectBeforeUpdate

When @Entity is removed, each and every attribute listed above will have its own annotation definition as listed below:

  1. DynamicInsert
  2. DynamicUpdate
  3. Immutable
  4. OptimisticLocking
  5. Persister
  6. Polymorphism
  7. SelectBeforeUpdate

However, the annotation Entity is deprecated in favor of the JPA annotation @javax.persistence.Entity. If you would like to use it, you have to use the JPA one instead of the hibernate annotation. It is obvious that there will be lot of changes with the hibernate API in the future versions, I would suggest to use the latest version if you are starting a new project.

Comments

comments

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Speak Your Mind

*

Close
Please support the site
By clicking any of these buttons you help our site to get better