开发者

Hibernate annotation

开发者 https://www.devze.com 2023-04-11 23:17 出处:网络
Should we use @org.hibernate.annotations.Entity instead of @javax.persistence.Entity in Hibernate based ap开发者_高级运维plications?

Should we use @org.hibernate.annotations.Entity instead of @javax.persistence.Entity in Hibernate based ap开发者_高级运维plications?

Or is there no such rule?


@org.hibernate.annotations.Entity complements @javax.persistence.Entity.

See this tightly related question for details: Difference between JPA Entity and Hibernate Entity. As stated there, you shouldn't be using @org.hibernate.annotations.Entity without @javax.persistence.Entity. The Hibernate annotation will let you add some extra hibernate-specific features to the ones already defined in the standard JPA one.

The JPA annotation has the advantange of decoupling your code from the specific engine you're using, and the Hibernate annotation adds some extra features/attributes to the JPA standard annotation, like optimisticLock. Only use @org.hibernate.annotations.Entity if you need to use those attributes.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号