java JOOQ 与 Hibernate
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29428231/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JOOQ vs Hibernate
提问by Gopal00005
When I chat to stackoverflowers on chat and read other tutorials about database with Java then they are guide me to use JOOQinstead of HIBERNATE.
当我在聊天中与 stackoverflowers 聊天并阅读有关 Java 数据库的其他教程时,他们会指导我使用JOOQ而不是HIBERNATE。
I am totally aware about ORM with Hibernate and I prefer to use Hibernate and now aware almost about JOOQ by reading tutorials and implementation on small projects.
我完全了解带 Hibernate 的 ORM,我更喜欢使用 Hibernate,现在通过阅读小项目的教程和实现几乎了解 JOOQ。
But I am confused what to choose and what is perfact for my dynamic web-applications which can be larger,medium or smaller, either Hibernate or JOOQ ?
但是我很困惑选择什么以及对于我的动态 Web 应用程序(可以是大、中还是小)(Hibernate 或 JOOQ)来说,什么是完美的?
BTW googled a lot but confused more and more...!!!Just Like : this,thisand this.
顺便说一句,谷歌搜索了很多,但越来越困惑......!!!就像:这个,这个和这个。
Which one is best for different conditions and situations for developer.?
哪一种最适合开发人员的不同条件和情况。?
回答by Lukas Eder
While jOOQ and Hibernate compete for the same target audience, they do not solve the same problem at all. You've already linked this article in your question. The essence of it is simple:
虽然 jOOQ 和 Hibernate 争夺相同的目标受众,但它们根本没有解决相同的问题。您已经在问题中链接了这篇文章。它的本质很简单:
- Are you going to solve object graph persistence problems? Use an ORM (e.g. Hibernate)
- Are you going to embed SQL into Java? Use SQL (e.g. jOOQ)
- 你打算解决对象图持久性问题吗?使用 ORM(例如 Hibernate)
- 您打算将 SQL 嵌入到 Java 中吗?使用 SQL(例如 jOOQ)
Of course, since both APIs cover accessing relational databases, they overlap in functionality to a certain extent. E.g. Hibernate also supports simple querying, while jOOQ also supports simple mapping.
当然,由于这两个 API 都包含访问关系数据库,因此它们在功能上有一定的重叠。例如 Hibernate 也支持简单查询,而 jOOQ 也支持简单映射。
While we should avoid delving into subjective discussions about whether object graph persistence or SQL is a better approach at interacting with your database, I think the above is a pretty objective answer to what API is better suited, once you've made the subjective decision.
虽然我们应该避免深入探讨对象图持久性或 SQL 是否是与数据库交互的更好方法的主观讨论,但我认为,一旦您做出主观决定,以上是对更适合哪种 API 的相当客观的回答。
AND: You can use both, e.g. ORM/Hibernate for CRUD, SQL/jOOQ for reporting.
AND:您可以同时使用两者,例如用于 CRUD 的 ORM/Hibernate,用于报告的 SQL/jOOQ。
(Disclaimer: I work for the company behind jOOQ, so this answer is biased)
(免责声明:我为 jOOQ 背后的公司工作,所以这个答案是有偏见的)