JDO vs JPA for Java on Google App Engine
Asked Answered
B

12

83

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.

Thanks.

Bayless answered 13/9, 2009 at 16:57 Comment(0)
N
31

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.

Nonrigid answered 13/9, 2009 at 17:20 Comment(9)
JDO is not dying, and is targetted at a different audience. Please do check your facts. JDO has had JDO 2.1, JDO 2.2 and now JDO 2.3. JDO is datastore independent. JPA is targetted solely for RDBMS. FactMaim
Well, I don't think we can say that JDO adoption is a success, no matter how much versions there are. Open your eyes, JDO could have billions of versions, nobody is using it anyway (and please, don't tell me JDO will reborn thanks to GAE). Then, if JPA is targeted solely for RDBMS, explain me why we can use this API with Google's BigTable? Thanks.Nonrigid
As JPA is backed by SUN. So for its standardization, I decided to go for it. I wonder why GAE put people to think between JDO and JPA. A religious matter it could be.Bayless
Guys, if Google chose it, then it's not dying. They know what they do. By the way, Congrats @DataNucleus. I've seen they choose your implementation.Baro
@Pascal JDO won't reborn for GAE. There is already Objectify which has born on GAE ?!:)Forficate
JDO is also Sun's standard , they donated JDO to Apache to develop the technology further.Allsopp
This a bad answer. JPA is rdbms specific. So, it cannot be used with the massive proliferation of alternative data stores ( the so called NoSQL ) that we have seen in the recent years. At least without making ugly compromises. So, please do not mark "JPA is daed" as the correct answerComforter
One should never choose options based on popularity. The whole GAE platform is based on big table and thats what JDO is there for!Rothstein
I agree with "One should never choose options based on popularity". Tools should be chosen for their appropriateness to the task at hand. Today there are 74 followers having asked 1.1K questions on JDO.This does not imply anything about "the death of JDO". It simply says IMHO that the number of people who feel that they are faced with the problems that JDO solves is small. Is the number of problems that JDO solves small? Is the low take up of JDO a marketing thing? JPA is geared generally, for relational data, and who has RDBM tools to sell push & promote? Rhetorical Question!Asch
M
34

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

Maim answered 14/9, 2009 at 17:1 Comment(7)
Why does the Google App Engine supports JPA for its BigTable datastore using the datanucleus-appengine plugin (quoting datanucleus.org/products/accessplatform/appengine/support.html) if it's a total mistake? Can you elaborate on this?Nonrigid
JPA support on non-RDBMS datastores involves making compromises on the API and query language. Many things don't fit so aren't supported since they are RDBMS-specific (significant parts of JPQL for example, or many JPA annotations, etc). Consequently you cannot have full portability across datastores, and so any argument for using JPA on BigTable being a straight copy across for what you'd use for an RDBMS store is false.Maim
For JDO on the other hand the query language (JDOQL) has no RDBMS-specific components, and metadata is database neutral on the whole with RDBMS-specific components separated out cleanly. Consequently you do have portability between datastores. The JDO API allows use of a native query language for each datastore where required.Maim
I never said that you can use the full JPA API but, to me, this won't prevent you from reusing your JPA knowledge so it's just not a valid reason for not using JPA. And BTW, portability accross datastores doesn't happen in real life.Nonrigid
Whatever I say you're not going to agree so it is pointless the discussion, nor necessary of bold type. Yes portability across datastores does happen since I've got clients doing just that. As always people should decide things for themselves based on their project needs, which is what we say in the DataNucleus docs. --Andy (DataNucleus)Maim
Andy, could you give an example or 2 of BigTable features that are not available with JPA? Even example of the feature that is possible with JPA but awkwardly would work...Lucio
I love how with GAE/J you can't use @Id as primary keys if you want to persist multiple different objects in a single transaction - you have to use Google's non-portable @Key instead.Karmenkarna
N
31

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.

Nonrigid answered 13/9, 2009 at 17:20 Comment(9)
JDO is not dying, and is targetted at a different audience. Please do check your facts. JDO has had JDO 2.1, JDO 2.2 and now JDO 2.3. JDO is datastore independent. JPA is targetted solely for RDBMS. FactMaim
Well, I don't think we can say that JDO adoption is a success, no matter how much versions there are. Open your eyes, JDO could have billions of versions, nobody is using it anyway (and please, don't tell me JDO will reborn thanks to GAE). Then, if JPA is targeted solely for RDBMS, explain me why we can use this API with Google's BigTable? Thanks.Nonrigid
As JPA is backed by SUN. So for its standardization, I decided to go for it. I wonder why GAE put people to think between JDO and JPA. A religious matter it could be.Bayless
Guys, if Google chose it, then it's not dying. They know what they do. By the way, Congrats @DataNucleus. I've seen they choose your implementation.Baro
@Pascal JDO won't reborn for GAE. There is already Objectify which has born on GAE ?!:)Forficate
JDO is also Sun's standard , they donated JDO to Apache to develop the technology further.Allsopp
This a bad answer. JPA is rdbms specific. So, it cannot be used with the massive proliferation of alternative data stores ( the so called NoSQL ) that we have seen in the recent years. At least without making ugly compromises. So, please do not mark "JPA is daed" as the correct answerComforter
One should never choose options based on popularity. The whole GAE platform is based on big table and thats what JDO is there for!Rothstein
I agree with "One should never choose options based on popularity". Tools should be chosen for their appropriateness to the task at hand. Today there are 74 followers having asked 1.1K questions on JDO.This does not imply anything about "the death of JDO". It simply says IMHO that the number of people who feel that they are faced with the problems that JDO solves is small. Is the number of problems that JDO solves small? Is the low take up of JDO a marketing thing? JPA is geared generally, for relational data, and who has RDBM tools to sell push & promote? Rhetorical Question!Asch
B
25

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

Barbuto answered 13/10, 2009 at 12:59 Comment(2)
This Datanucleus' manifesto seems to be very pro-JDO. All their statements seem critical of JPA and defensive of JDO and yet I find using JPA a happier activity than using JDO.Literality
DataNucleus supports both JDO and JPA, and we actually just included most of JPA2 in DN 2.0. We promote both, unlike all other persistence solutions, and let users choose. If you think there are factual errors in any coverage of JDO or JPA we would welcome your input. If part of a political agenda on your behalf then you're best advised to keep your feelings to yourselfMaim
D
17

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

Disrobe answered 28/1, 2010 at 17:6 Comment(1)
I am a happy JDO user: it suits me fine once I got used to it. Also, with JDO I have the option of moving away from GAE/J and Google BigTable without completely re-designing my persistent data exchange.Equitable
G
13

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.

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.

Gutsy answered 10/2, 2011 at 6:3 Comment(0)
D
11

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

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.

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

However, Google does not recommend any of them.

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

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

http://gaejava.appspot.com/

For example, add 10 entity

Python :68ms

JDO :378ms

Java Native :30ms

Dolli answered 31/8, 2011 at 23:58 Comment(1)
That's not the kind of results I get when I run your tests.Ferris
N
9

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

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".

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.

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.

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.

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?

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.

Neurologist answered 14/7, 2012 at 15:48 Comment(0)
R
7

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!

Roeder answered 15/7, 2010 at 0:33 Comment(0)
S
6

What I think is terrible about using JDO at the time of writing this is that the only implementation vendor is Datanucleus and the drawbacks of that is the lack of competition which leads to numerous issues like:

  1. A not very detailed documentation about some aspects like extensions
  2. You usually get sarcastic responses from the authors like (Have you checked the logs ? May be there is a reason for having them) and annoying responses like that
  3. You don't get an answer to your question in a helpful amount of time, sometimes if you get an answer in less than 7 days, you should consider your self lucky, even here on StackOverflow

I'm always hoping for someone to start implementing the JDO specification themselves, may be then they'll offer something more and hopefully more free attention to the community and not always bothering about being paid for support, not saying that Datanucleus authors only care about commercial support, but I'm just saying.

I personally consider Datanucleus authors has no obligation whatsoever to Datanucleus itself nor it's community. They can drop the whole project at anytime and no one can judge them for it, it's their effort and their own property. But you should know what you are getting into. You see, when one of us developers look for a framework to use, you cannot punish or command the framework's author, but on the other hand, you need your work done ! If you had time to write that framework, why would you look for one in the first place ?!

On the other hand, JDO itself has some complications like objects life cycle and stuff which isn't very intuitive and common (I think).

Edit: Now I know also JPA enforces the object life cycle mechanism, so it looks like its inevitable to deal with persisted entities life cycle states if you wish to use a standard ORM API (i.e. JPA or JDO)

What I like most about JDO is the ability to work with ANY database management system without considerable effort.

Sarcoma answered 28/1, 2013 at 18:46 Comment(1)
You're right about almost every observation. ORM is a pain in the ass for some complex persistent objects (months of debug, literally!). Currently i'm stuck with DN 2.1 because a property was changed and my code will not work with newer versions. That said, DN with JDO is the way to go, in my opinion.Weinhardt
P
3

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.

Petite answered 5/6, 2010 at 9:30 Comment(0)
B
3

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

Bruner answered 18/8, 2010 at 16:30 Comment(5)
Do you have a source for this?Esdras
Downvoted because I don't think this is true, can't find any info online to support it, and there's no evidence provided with the post.Shrier
The roadmap mentions a full featured SQL database is in the works code.google.com/appengine/business/roadmap.htmlGad
Funny but now (31-08-2011) we found that it was not true at all.Dolli
Not true? Google's App Engine SQL Preview (beta) URL is pretty long, so I've shortened it goo.gl/AhsxX (thought the need to explain just in case you're a non-believer).Gaylenegayler
P
1

Neither!

Use Objectify, because is cheaper (use less resources) and is faster. FYI: http://paulonjava.blogspot.mx/2010/12/tuning-google-appengine.html

Objectify is a Java data access API specifically designed for the Google App Engine datastore. It occupies a "middle ground"; easier to use and more transparent than JDO or JPA, but significantly more convenient than the Low-Level API. Objectify is designed to make novices immediately productive yet also expose the full power of the GAE datastore.

Objectify lets you persist, retrieve, delete, and query your own typed objects.

@Entity
class Car {
    @Id String vin; // Can be Long, long, or String
    String color;
}

ofy().save().entity(new Car("123123", "red")).now();
Car c = ofy().load().type(Car.class).id("123123").now();
ofy().delete().entity(c);
Pangaro answered 4/7, 2013 at 23:37 Comment(2)
is this for datastore only? how about cloud sql?Rockabilly
And the downside is you become tightly tied to the vendor. Not always a problem but the whole point of JDO is to avoid that. (talking as the one who is probably gonna use it for small services).Curlicue

© 2022 - 2024 — McMap. All rights reserved.