简体   繁体   English

Hibernate - 注释和公共注释之间的区别?

[英]Hibernate - difference between annotations and commons-annotations?

To keep it short and sweet: 保持简短和甜美:

There is hibernate-commons-annotations 4.1.0-Final and hibernate-annotations 3.5.6-Final. 有hibernate-commons-annotations 4.1.0-Final和hibernate-annotations 3.5.6-Final。

I'm a nub, what's the difference between them, and do I need them both? 我是个小伙子,他们之间有什么区别,我需要他们两个吗?

Trying to "avoid" JPA and by that I mean using the JPA 2.0 standards embedded within Hibernate. 试图“避免”JPA,我的意思是使用嵌入在Hibernate中的JPA 2.0标准。

Thanks! 谢谢!

Previously, hibernate-annotations was released and versioned from hibernate core. 以前,hibernate-annotations是从hibernate核心发布和版本化的。 But from version 3.5 and up it is included with hibernate core. 但是从3.5及更高版本开始,它包含在hibernate核心中。 And for some reason it was still released from 3.5.0 to 3.5.6 but you do not need it anymore. 由于某种原因,它仍然从3.5.0发布到3.5.6,但你不再需要它了。

And coming to hibernate-commons-annotations, it is a utility project used by annotations based hibernate sub-projects. 并且进入hibernate-commons-annotations,它是一个基于注释的hibernate子项目使用的实用程序项目。 It is used by other hibernate projects like hibernate-search and thus is maintained as a separate project and it is a compile time dependency for hibernate-core v3.6.0 and up. 它被其他hibernate项目(如hibernate-search)使用,因此作为一个单独的项目进行维护,它是hibernate-core v3.6.0及更高版本的编译时依赖项。

Source 1 Source 2 来源1 来源2

Hibernate Commons Annotations is "Utility project for annotation handling", as said for example here . Hibernate Commons Annotations是“用于注释处理的实用程序项目”,例如这里所说的。 It does not contain such API that normal user of Hibernate should use. 它不包含Hibernate的普通用户应该使用的API。

Hibernate annotations contained persistence mapping annotations and related code. Hibernate注释包含持久性映射注释和相关代码。 Nowadays it is merged to Hibernate core. 现在它被合并到Hibernate核心。

If you really want to avoid JPA (1/2) that is easily done by not using classes from javax.persistence package or from its subpackages. 如果你真的想避免通过不使用javax.persistence包或其子包中的类而轻松完成的JPA(1/2)。 If you want opposite, use javax.persistence and avoid org.hibernate packages where possible. 如果你想要相反,请使用javax.persistence并尽可能避免使用org.hibernate包。

Good guide to get started with Hibernate can be found from http://docs.jboss.org/hibernate/orm/4.1/quickstart/en-US/html_single/ . 可以在http://docs.jboss.org/hibernate/orm/4.1/quickstart/en-US/html_single/找到开始使用Hibernate的好指南。 It also tells which libraries are needed always and which ones are optional. 它还告诉我们总是需要哪些库以及哪些库是可选的。

Reference documentation contains plenty of advices about using JPA instead of deprecated legacy Hibernate annotations. 参考文档包含大量有关使用JPA而不是弃用的旧Hibernate注释的建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM