When I annotate a class with @Entity and try to resolve the dependencies, I get to choose the package between two different packages, javax.persistence.Entity and org.hibernate.annotations.Entity
The javax package is JPA’s entity-annotation, but why is there a hibernate entity-annotation and difference does it have with JPA’s annotation? Is it just an extension to allow more attributes to be defined?
org.hibernate.annotations.Entityhas some extra attributes thatjavax.persistence.Entityhas not standarized. The extra features will only work if using hibernate’sAnnotationConfigurationdirectly or if hibernate is the JPA provider.from the FAQ:
edit: new link the specific question:
edit: new link the answer:
For instance, there is an attribute called
optimisticLock, which tells hibernate whether to use the standard version column or to compare all columns when updating. This behavior is not in the JPA spec, so in order to configure it, you must use hibernate specific extension found in their own annotation.Like this: