I'm new to O/R Mappers. I would like to know more about JDO, Hibernate, Castor. Which is the best option? What are the advantages and disadvantages of each of these. How each of these differ from each other? What are the other alternatives?
Unfortunately, I have little experience with JDO or Castor (read: none), though I've recently started using Hibernate after reading O'Reilly's Hibernate: A Developer's Notebook. I've found it fairly easy to use and quick to get going with.
There is a bit of a learning curve to switching over, and you kind of have to get used to the XML syntax needed to generate the mappings and Java, but beyond that, I've had few problems or complaints. (I suspect switching to any ORM tool requires a learning curve.) But as I said, it's been fairly flexible in all the ways I've needed it to be thus far, and it's fairly quick to use once you get used to it. [ August 16, 2004: Message edited by: Theodore Casser ]
Theodore Jonathan Casser
SCJP/SCSNI/SCBCD/SCWCD/SCDJWS/SCMAD/SCEA/MCTS/MCPD... and so many more letters than you can shake a stick at!
Joined: Apr 21, 2002
Thanks for your reply. There are high chances of using JDO in our project. So would like to know more about JDO. Moreover i learnt that JDO is a standard and it is portable while Hibernate is not. What are the features available in Hibernate that is not available in JDO or vice versa. Is it that developers started using Hibernate that they do not want to switch to JDO.
Actually, I can't see any reason Hibernate isn't portable, since it's all Java-based. (There's nothing OS-specific in it.) But unfortunately, I don't know much about JDO, so I can't help you there, really.
Let me just add to the original question. All three are quite similar.
JDO is an object persistence standard - note that I did not say "O/R mapping standard". JDO is also geared towards persistence into object databases.
Hibernate is possibly the most popular Java O/R mapper. It is not JDO compatible, but arguably easier to use and more powerful than many JDO implementations.
Castor, in my experience, is a nearly-static product. Two years ago they were way ahead of the pack, but they've hardly moved since. I would not recommend it.
Originally posted by anitha lingam: Moreover i learnt that JDO is a standard and it is portable while Hibernate is not.
True. It is up to you (or your managers) to judge how important that is. Avoid knee-jerk choices, though: JDO object-relational mapping is not standardised, just the programming model, so your JDO applications are more locked-in than you might think. Hibernate has a momentum that isn't that much smaller than that of JDO, and it is in more powerful and flexible in a number of ways. Not coincidentaly, the tool has made a definite impact on the of JDO 2.0 and EJB 3 standards-in-progress.
What are the features available in Hibernate that is not available in JDO or vice versa.
JDO is standard, and supports object databases. Hibernate is more mature, has a query language (HQL) which is more powerful and quite intuitive if you know SQL, does not require bytecode processing, and allows you to disconnect an object graph, update it in another tier and later reconnect it to persist the update.
Is it that developers started using Hibernate that they do not want to switch to JDO.
They believe that JDO represents an inferior product, and I don't think Gavin King was very impressed with the way the JDO 2 expert group is going.
Joined: Apr 21, 2002
Thanks for all the replies.
Basically I have the following requirements in my application. 1. Object persistence 2. Performance 3. Database Independence
Can I know how Hibernate/JDO caters to each of these requirements?
I dont know about performance (Hibernate guys say that it is scalable Hibernate is a powerful, ultra-high performance object/relational persistence and query service for Java. There are many implementations of JDO so performance could vary ) but other two requirements should be met by both Hibernate and JDO.
The Hibernate idea will also be used in EJB 3.0.
Joined: Apr 21, 2002
Regarding the portability with datasources, my application requires data to be written from the database to flat files and vice versa. Can this be acheived by both Hibernate and JDO?
Originally posted by anitha lingam: Regarding the portability with datasources, my application requires data to be written from the database to flat files and vice versa. Can this be acheived by both Hibernate and JDO?
Flat files? Hibernate doesn't work with flat files.
Originally posted by Peter den Haan: [...] All three are quite similar.[...]
... in intention (to be read persistence), while the target is quite different. While JDO spec aims to offer the generic solution for persistence (to any possible storage - I think this requires lots of guts), while ORMs target only to solve the so-called object-relational paradigm mismatch.
You can easily persist things to a file, e.g. use HSQL DB, which uses a single text file to hold the database. In Hibernate, you could have two SessionFactories (one for your normal RDBMS and one for HSQL DB) and then load and persist object graphs between them.
XML is just the same as flat files, after all, its just a text file format. There is no real reason why it should be used for data storage and data management.
Co-Author of <a href="http://www.manning.com/bauer" target="_blank" rel="nofollow">Hibernate in Action</a>