Google App Engine 上的 JDO 与 JPA for Java

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1418219/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 11:52:53  来源:igfitidea点击:

JDO vs JPA for Java on Google App Engine

javagoogle-app-enginejpajdo

提问by Tahir Akram

I want to develop my project on Google App Engine with Struts2. For the database I have two options JPA and JDO. Will you guys please suggest me on it? Both are new for me and I need to learn them. So I will be focused on one after your replies.

我想使用 Struts2 在 Google App Engine 上开发我的项目。对于数据库,我有两个选项 JPA 和 JDO。你们会建议我吗?两者对我来说都是新的,我需要学习它们。所以我会在你回复后专注于一个。

Thanks.

谢谢。

采纳答案by Pascal Thivent

JPA is Sun's standard for persistence, JDO is IMHO dying (actually, it's dead but still moving). In other words, JPA seems to be a better investment on the long term. So I guess I'd choose JPA if both were new to me.

JPA 是 Sun 的持久性标准,JDO 恕我直言正在消亡(实际上,它已经死了但仍在移动)。换句话说,从长远来看,JPA 似乎是更好的投资。所以我想如果两者对我来说都是新的,我会选择 JPA。

回答by DataNucleus

The GAE/J google group has several posts about this very thing. I'd do a search on there and look at people's opinions. You will get a very different message to the opinions expressed above. Also focus on the fact that BigTable is not an RDBMS. Use the right tool for the job

GAE/J 谷歌小组有几篇关于这件事的帖子。我会在那里进行搜索并查看人们的意见。你会得到与上述观点截然不同的信息。还要注意 BigTable 不是 RDBMS 的事实。为工作使用正确的工具

回答by Vinod

Just saw this comparison between JPA and JDO by DataNucleus themselves:- http://www.datanucleus.org/products/accessplatform_2_1/jdo_jpa_faq.htmlAn eye-opener.

刚刚通过 DataNucleus 自己看到了 JPA 和 JDO 之间的这种比较:- http://www.datanucleus.org/products/accessplatform_2_1/jdo_jpa_faq.html令人大开眼界。

回答by Manfred

I'm a happy user of JDO. Keep up the good work guys.

我是 JDO 的快乐用户。保持良好的工作伙计们。

回答by prateek mathur

JPA is the way to go as it seems to be pushed as a standardized API and has recently got momentum in EJB3.0.. JDO seems to have lost the steam.

JPA 是要走的路,因为它似乎是作为标准化 API 推出的,并且最近在 EJB3.0 中获得了动力。JDO 似乎已经失去了动力。

回答by corydoras

Go JDO. Even if you don't have experience in it, it is not hard to pick up, and you will have a new skill under your belt!

去JDO。即使你没有这方面的经验,上手也不难,你将拥有一项新技能!

回答by stanlick

GAE/J is slated to add MYSQL before the end of the year.

GAE/J 计划在年底前添加 MYSQL。

回答by surge

People claiming JDO is dead is not without merit. Here is what I read in the book Pro EJB 3 Java Persistence API: "Shortly thereafter Sun announced that JDO would be reduced to specification maintenance mode and that the Java Persistence API would draw from both JDO and the other persistence vendors and become the single supported standard going forward.". The author Mike Keith is the co-specification leader on EJB3. Of course he is a big supporter of JPA, but I doubt he is biased enough to lie.

声称 JDO 已死的人并非没有道理。这是我在 Pro EJB 3 Java Persistence API 一书中读到的内容:“此后不久,Sun 宣布 JDO 将缩减为规范维护模式,并且 Java Persistence API 将从 JDO 和其他持久性供应商中汲取并成为唯一受支持的标准向前发展。”。作者 Mike Keith 是 EJB3 的共同规范负责人。当然,他是 JPA 的坚定支持者,但我怀疑他是否有偏见以至于撒谎。

It is true that when the book was published, most major vendors were united behind JPA rather than JDO, even though JDO does have more advanced technical features than JPA. It is not surprising because big players in the EE world such as IBM/Oracle are also big RDBMS vendors. More customers are using RDMBS than non-RDMBS in their projects. JDO was dying until GAE gave it a big boost. It makes sense because GAE data store is not relational database. Some JPA features does not work with bigtable such as aggregation queries, Join queries, owned many-to-many relationships. BTW, GAE supports JDO 2.3 while only support JPA 1.0. I will recommend JDO if GAE is your target cloud platform.

的确,当本书出版时,大多数主要供应商都团结在 JPA 而不是 JDO 背后,尽管 JDO 确实具有比 JPA 更先进的技术特性。这并不奇怪,因为 EE 世界中的大玩家,例如 IBM/Oracle,也是大的 RDBMS 供应商。在他们的项目中使用 RDMBS 的客户多于非 RDMBS。JDO 正在消亡,直到 GAE 给它一个巨大的推动。这是有道理的,因为 GAE 数据存储不是关系数据库。某些 JPA 功能不适用于 bigtable,例如聚合查询、联接查询、拥有多对多关系。顺便说一句,GAE 支持 JDO 2.3 而只支持 JPA 1.0。如果 GAE 是您的目标云平台,我会推荐 JDO。

回答by magallanes

For the record, it is Google App Engine (GAE), so we play with the Google rules not with the Oracle/Sun rules.

作为记录,它是 Google App Engine (GAE),所以我们使用 Google 规则而不是 Oracle/Sun 规则。

Under it, JPA is not suitable for GAE, it is unstable and it does not work as expected. Neither Google is willing to support it but the bare minimum.

在它之下,JPA 不适合 GAE,它不稳定,无法按预期工作。谷歌都不愿意支持它,但最低限度。

And for other part, JDO is quite stable in GAE and it is (in some extend) well documented by Google.

而对于其他部分,JDO 在 GAE 中非常稳定,并且(在某种程度上)谷歌有很好的文档记录。

However, Google does not recommend any of them.

但是,Google 不推荐其中任何一个。

http://code.google.com/appengine/docs/java/datastore/overview.html

http://code.google.com/appengine/docs/java/datastore/overview.html

Low-level API will give the best performance and GAE is all about performance.

低级 API 将提供最佳性能,而 GAE 就是性能。

http://gaejava.appspot.com/

http://gaejava.appspot.com/

For example, add 10 entity

例如,添加 10 个实体

Python :68ms

JDO :378ms

Java Native :30ms

蟒蛇:68ms

JDO :378ms

Java 原生:30 毫秒

回答by 99Sono

In race between JDO vs JPA I can only agree with the datanucleus posters.

在 JDO 与 JPA 之间的竞赛中,我只能同意 datanucleus 海报。

First of all, and also most importantly, the posters of datanucleus know what they are doing. They are after all developing a persistent library and are familiar with data models other than the relational, e.g. Big Table. I am sure that id a developer for hibernate were here, he would have say: "all our assumptions when building our core libraries are tightly coupled to relational model, hibernate is not optimized for GAE".

首先,也是最重要的,datanucleus 的海报知道他们在做什么。毕竟,他们正在开发一个持久性库,并且熟悉关系以外的数据模型,例如大表。我确信 hibernate 的开发人员在这里,他会说:“我们在构建核心库时的所有假设都与关系模型紧密耦合,hibernate 没有针对 GAE 进行优化”。

Secondly, JPA is unquestionably in more widespread use, being a part of the official Java EE stack helps a bit, but that does not necessarily mean that it is better. In fact, JDO, if you read about it, corresponds to a higher level of abstraction than JPA. JPA is tightly coupled to the RDBMS data model.

其次,JPA 无疑得到了更广泛的使用,成为官方 Java EE 堆栈的一部分会有所帮助,但这并不一定意味着它更好。事实上,如果您阅读过 JDO,它对应于比 JPA 更高的抽象级别。JPA 与 RDBMS 数据模型紧密耦合。

From a programming stand point, using the JDO APIs is a much better option, because you are conceptually compromising a lot less. You can switch, theoretically to any data model of your desire, provided the provider you use supports the underlying database. (In practice you rarely achieve such a high level of transparancy, because you will find yourself setting your primary keys on GAE's object and you will be tying yourself to a specific database provider, e.g. google). it will still be easier to migrate though.

从编程的角度来看,使用 JDO API 是一个更好的选择,因为您在概念上的妥协要少得多。理论上,您可以切换到您想要的任何数据模型,前提是您使用的提供程序支持底层数据库。(实际上,您很少能达到如此高的透明度,因为您会发现自己在 GAE 的对象上设置主键,并且将自己绑定到特定的数据库提供商,例如 google)。尽管如此,它仍然会更容易迁移。

Thirdly, you can use Hibernate, Eclipse Link, and even spring with GAE. Google seems to have made a big effort to allow you to use the frameworks you are used to building your applications on. But what people realize when they build their GAE applications as if they were running on RDBMS is that they are slow. Spring on GAE is SLOW. You can google Google IO videos on this topic to see that it is true.

第三,您可以使用 Hibernate、Eclipse Link,甚至是 Spring 和 GAE。Google 似乎做出了很大努力,让您可以使用用于构建应用程序的框架。但是,当人们像在 RDBMS 上运行一样构建 GAE 应用程序时,他们意识到它们很慢。GAE 上的春天很慢。你可以谷歌谷歌关于这个主题的 IO 视频,看看它是真的。

Also, adhering to standards is a good sensible thing to do, in principle I applaud. On the other hand, JPA being part of the Java EE stack makes people, at times, lose their notion of options. Realize, if you will, that Java Server Faces is also part of the Java EE stack. And it is an unbelievably tidy solution for web GUI development. But in the end, why do people, the smarter people if I may say so, deviate from this standard and use GWT instead?

另外,坚持标准是明智之举,原则上我赞成。另一方面,JPA 是 Java EE 堆栈的一部分,有时会让人失去选项的概念。如果您愿意,请意识到 Java Server Faces 也是 Java EE 堆栈的一部分。对于 Web GUI 开发来说,这是一个令人难以置信的整洁解决方案。但最终,为什么人们,更聪明的人,如果我可以这么说,偏离这个标准而使用 GWT 呢?

In all of this, I have to sate that there is one very significant thing going for JPA. That is Guice and its convenient support for JPA. Seems that google was not as smart as usual in this point and are content, for now in not supporting JDO. I still think that they can afford it, and eventually Guice will engulf JDO as well,... or maybe not.

在所有这些中,我必须声明 JPA 有一件非常重要的事情。这就是 Guice 及其对 JPA 的便捷支持。似乎谷歌在这一点上不像往常那样聪明并且很满意,因为现在不支持 JDO。我仍然认为他们负担得起,最终 Guice 也将吞没 JDO,……或者可能不会。