org.hibernate.annotations.Entity
has some extra attributes that javax.persistence.Entity
has not standarized. The extra features will only work if using hibernate's AnnotationConfiguration
directly or if hibernate is the JPA provider.
from the FAQ:
I use @org.hibernate.annotations.Entity and get an Unknown entity exception
Always import @javax.persistence.Entity
@org.hibernate.annotations.Entity completes @javax.persistence.Entity but is not a replacement
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:
@Entity
@org.hibernate.annotations.Entity(optimisticLock=OptimisticLockType.ALL)
public class MyEntity implements Serializable {
...
}