What is the difference between @Entity in Hibernate and JPA

jettisamba picture jettisamba · Oct 28, 2014 · Viewed 8.6k times · Source

When i am doing sample Hibernate standalone program, little bit confusing was created in my mind with the usage of @Entity annotation.

Here my question is, I have one persisted class with @Entity from javax.persistence package then it's working fine but when i replaced @Entity annotation with Hibernate API(i.e from org.hibernate.annotations package) then it's giving org.hibernate.MappingException: Unknown entity: com.jetti.test.Employee

Give some more explanation are highly appreciated.

Answer

Predrag Maric picture Predrag Maric · Oct 28, 2014

@javax.persistence.Entity is still mandatory, @org.hibernate.annotations.Entity is not a replacement.

Documentation

So, hibernate's @Entity just complements the javax.persistence.Entity, and gives a few more fine tuning options.