GeeCON Prague 2014*
The moose likes Struts and the fly likes Spring and JDO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Spring and JDO " Watch "Spring and JDO " New topic
Author

Spring and JDO

Emman lopez
Ranch Hand

Joined: Mar 11, 2004
Posts: 38
Hi Matt,
I would like to know when deciding for a persistence framework which is better to use with Spring , JDO or Hibernate. My company is using struts and JDO right now, I would like to suggest spring to my boss, but I am a spring newbie. any advice ........

thanks in advance.


E.L.<br /> <br />SCJP
Matt Raible
author
Ranch Hand

Joined: Jan 11, 2001
Posts: 114
If you have experience with JDO, I'd stick with JDO. Spring has good support for JDO and it's quite easy to create a JDO DAO. Here's some examples from Chapter 7 - comparing a Hibernate DAO and a JDO DAO.

JDO Version:


Hibernate version:


In the book, I use JPOX and it's (early) JDO 2.0 support.


Matt<br /> <br />Author: <a href="http://springlive.com" target="_blank" rel="nofollow">Spring Live</a> and <a href="http://www.apress.com/book/bookDisplay.html?bID=256" target="_blank" rel="nofollow">Pro JSP</a><br />Weblogs: <a href="http://raibledesigns.com" target="_blank" rel="nofollow">Raible Designs</a> <a href="http://jroller.com/page/raible" target="_blank" rel="nofollow">Spring Live Blog</a>
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
As Matt already pointed out the solution is pretty much the same, so I think that you must continue with JDO - at least for the fact you already have knowledge of it and you already evaluate it.

./pope


blog - InfoQ.com
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
If you have experience with JDO, I'd stick with JDO. Spring has good support for JDO and it's quite easy to create a JDO DAO. Here's some examples from Chapter 7 - comparing a Hibernate DAO and a JDO DAO.


What is/are different between JDO and Hibernate?

When to use JDO/Hibernate?

thank you.


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Matt Raible
author
Ranch Hand

Joined: Jan 11, 2001
Posts: 114
Originally posted by somkiat puisungnoen:


What is/are different between JDO and Hibernate?

When to use JDO/Hibernate?


The main difference is that JDO is a "standard" while Hibernate is a widely successful open source project. It's similar to JSF and Struts. The standards tend to get adopted by large companies while the open-source projects have often proved their worthiness by usage.

When to use one or the other? That really depends on your company and your project. I prefer to use Hibernate on my projects, but when an O/R mapping tool doesn't work, I use iBATIS, which allows me to write SQL. Spring has supporting classes for iBATIS too. And, of course, it's covered in the book.
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995

I prefer to use Hibernate on my projects, but when an O/R mapping tool doesn't work, I use iBATIS, which allows me to write SQL.


I guess you know you can write SQL in Hibernate too. I am wandering what do you mean by doesn't work? (it is a matter of scalability, performance, etc?).

./pope
Matt Raible
author
Ranch Hand

Joined: Jan 11, 2001
Posts: 114
Originally posted by Ali Pope:


I guess you know you can write SQL in Hibernate too. I am wandering what do you mean by doesn't work? (it is a matter of scalability, performance, etc?).


I was on a project last year where we needed to migrate an existing JDBC app to something a little cleaner. The SQL statements in the Java code where enourmous and sometimes joined 5 or 6 tables. By using iBATIS, we were able to simply pull the SQL out of Java classes and put them in XML.

As for writing SQL with Hibernate, that's new and wasn't available at the time. In my experience, it's best to choose your persistence framework for what it's good at. Hibernate shouldn't be the hammer than solves all your problems. There are many other excellent frameworks out there.
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Matt about choosing the best suitable solution I fully agree with you.

I was not quite sure what you meant by Hibernate not working (...and I am not a Hibernate advocate either ).

These tones of SQL bothers me from time to time. I would like to see a solution where your queries are compile time checked (the Criteria work on Hibernate is a good start for this).

./pope
Emman lopez
Ranch Hand

Joined: Mar 11, 2004
Posts: 38
Thanks guys for your input, I hear everyone talking about hibernate, I guess it should be very very good.
Emman lopez
Ranch Hand

Joined: Mar 11, 2004
Posts: 38
I am planning to use Kodo JDO implementation, I wonder if they are thinking to create libraries for Spring, also I heard IntelliJ IDEA IDE were planning to have support for Spring Framework, anyone knows if they are going to release it soon?
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
What do you mean by Kodo libraries for Spring?
I don't know about a Spring plugin in Idea, but I can tell you that such a plugin is already available for Eclipse .

./pope
Matt Raible
author
Ranch Hand

Joined: Jan 11, 2001
Posts: 114
Originally posted by Emman lopez:
I am planning to use Kodo JDO implementation, I wonder if they are thinking to create libraries for Spring, also I heard IntelliJ IDEA IDE were planning to have support for Spring Framework, anyone knows if they are going to release it soon?


Spring's
JDO Support classes are not implementation specific, so what works with one implementation of JDO should work with another. The nice thing about Kodo and JPOX is they've each published sample apps or tutorials of how to use Spring with their products.

Kodo JDO + Spring Sample
JPOX and Spring Tutorial
 
GeeCON Prague 2014
 
subject: Spring and JDO