wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Learning Hibernate & Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Learning Hibernate & Spring" Watch "Learning Hibernate & Spring" New topic
Author

Learning Hibernate & Spring

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Hi all.
I heared a lot about Spring framework and hibernate and I really want to play with them.
but I have some questions :
1. are they an easy to learn technologies ?
2. can I relay on their documentation to learn these technologies.
I don't want to spend some money right now on some books.
3. is hibernate a replacement for JDBC and spring a replacement for EJB ?
thanks.
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
In order:
1. as any tech they need some attention from the developer. Hibernate is not putting very much presure on dev and following the quick indications found in the documentation will help you to have it working painless. As for Spring, if you feel comfortable with lightweight container you will make it.

2. Hibernate and Spring have the best documentations I ever seen on open source projects.

3. Hibernate is an ORM (Object/Relational Mapping framework) helping the developer to concentrate on Object world (decoupling the OO from relational world - SQL). Spring is a lightweight container and so in a way could be seen as a replacement of application server (containers).

./pope


blog - InfoQ.com
Theodore Casser
Ranch Hand

Joined: Mar 14, 2001
Posts: 1902

Having been playing with Hibernate for a while now (I'm in the progress of rewriting an application to use it), I can say it is very easy to learn. I did, however, pick up a book - Hibernate: A Developer's Notebook - to get a jump-start on it, but from having perused the documentation and forums on the website, they seem to give enough information to get one going quickly.

It really is very easy to learn, so much so that you'll be surprised.


Theodore Jonathan Casser
SCJP/SCSNI/SCBCD/SCWCD/SCDJWS/SCMAD/SCEA/MCTS/MCPD... and so many more letters than you can shake a stick at!
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
hi

1. both, spring and hibernate, are easy to start with. might get more complicated if you get over the "hello world" stuff and try to solve some real world problems with 'em.
2. both projects have good documentation, i would even say that they are among the best docs i've seen for open source / non commercial projects. i know from myself that writing docs is not the fun part so i really appreciate the docs hibernate and spring team created.
(i would not go for the "developers notebook" since it only covers the easy things you can also get from the (excelent) hibernate docs. i dont know about the "hibernate in action" yet (i ordered it on bookpool but they are out of stock) but i guess you get more insights.)
3. hibernate builds upon JDBC. it can be a replacement for your own persistence code if you need to persist Object to a RDBMS (how many times have you written the same stupid try/catch/finally PreparedStatement-ResultSet stuff over and over in your code ?)

cheers

pascal
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Originally posted by pascal betz:
[...] (how many times have you written the same stupid try/catch/finally PreparedStatement-ResultSet stuff over and over in your code ?)


LOL. You will still need some try/catch/finally in Hibernate2 to manage the Session (to solve the HibernateExceptions ;-)). This is changed only in Hibernate3 where HibernateException is now runtime exception.

./pope
Joao Vitor Guimaraes
Greenhorn

Joined: Nov 02, 2002
Posts: 4
I'm using Spring and Hibernate and i'm pretty happy with both.

The petclinic sample application that comes with spring is a good start
point to see this two great applications together.

Try using facades with BeanNameAutoProxyCreator making spring inject
the transaction interceptors into all *Facades beans.

In many cases I just say bye to SLSBs


Joao Vitor Lacerda Guimaraes<br />SCJP 1.4, SCJP 5.0<br />Belo Horizonte - Minas Gerais - Brazil
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Originally posted by John Todd:
Hi all.
I heared a lot about Spring framework and hibernate and I really want to play with them.
but I have some questions :
1. are they an easy to learn technologies ?
thanks.


Both technology is easy to learn Because both tectnology have several tutorial/document on the internet.

Hibernate : http://hibernate.org
Spring Framework : http://springframework.com


Originally posted by John Todd:
Hi all.
I heared a lot about Spring framework and hibernate and I really want to play with them.
but I have some questions :

2. can I relay on their documentation to learn these technologies.
I don't want to spend some money right now on some books.

thanks.

Yes, you can.

But you shoulde be have some book, it better than..

Originally posted by John Todd:
Hi all.
I heared a lot about Spring framework and hibernate and I really want to play with them.
but I have some questions :
3. is hibernate a replacement for JDBC and spring a replacement for EJB ?
thanks.


Hibernate is

Hibernate is a powerful, ultra-high performance object/relational persistence and query service for Java. Hibernate lets you develop persistent classes following common Java idiom - including association, inheritance, polymorphism, composition and the Java collections framework. The Hibernate Query Language, designed as a "minimal" object-oriented extension to SQL, provides an elegant bridge between the object and relational worlds. Hibernate also allows you to express queries using native SQL or Java-based Criteria and Example queries. Hibernate is now the most popular object/relational mapping solution for Java.


SpringFramework is

Java/J2EE application framework based on [Expert One-on-One J2EE Design and Development] by Rod Johnson. Includes JavaBeans-based configuration, an AOP framework, declarative transaction management, JDBC and Hibernate support, and a web MVC framework.



SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
Ali

LOL. You will still need some try/catch/finally in Hibernate2 to manage the Session (to solve the HibernateExceptions ;-)). This is changed only in Hibernate3 where HibernateException is now runtime exception


if you use Springframeworks HibernateTemplate, then you do not have to care for the checked Exceptions. HibernateTemplate (API) only throws DataAccessException (API) (check also all the subclasses) which is a Rutime Exception.

pascal
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Originally posted by pascal betz:
Ali


if you use Springframeworks HibernateTemplate, then you do not have to care for the checked Exceptions. HibernateTemplate (API) only throws DataAccessException (API) (check also all the subclasses) which is a Rutime Exception.

pascal


10x pascal. I am not currently using Spring - so I left out this piece of info. My mistake.

./pope
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Mind if I second the opinions voiced above? My team is an early Spring adopter. We have used both Spring and Hibernate on some chunky projects and are very happy with both of them.
  • are they an easy to learn technologies ? Well, how much do you already know, what parts of Spring do you want to adopt, and are you an easy learner? The transparent persistence of O/R mappers (Hibernate, in this case) can throw you initially if you're just used to JDBC. It will take a bit of time for you to get the hang of producing a good O/R mapping. The Spring framework is actually a multitude of frameworks. It's huge. Fortunately it's all independent, so you can pick the stuff you're interested in and learn it bit by bit. What might take you a bit of time is getting to grips with AOP concepts, but fortunately you can use declarative transaction support without understanding AOP. Similarly, the flexibility of the MVC framework might confuse you: compared to, say, Struts, it can be elusive because it is so much less rigid. It's worth it though.
  • can I relay on their documentation to learn these technologies. I can only echo what has already been said: documentation for both projects is well above average. Do buy a few books, though, certainly if you're working in a commercial setting: they will quickly earn themselves back.
  • is [...] spring a replacement for EJB? It is and it isn't. It does not attempt to replace EJBs in the things they were designed for, specifically distributed systems and MDBs; it complements and enhances EJBs in such cases. However, it does provide an alternative for a couple of common situations where EJBs are a less than perfect fit, for example the business tier in a collocated (single-JVM) system where you might use EJBs simply to give structure to your code and benefit from their declarative transactions. In such situations, Spring does a much better job than EJBs used to do.
  • Do explore the Spring/Hibernate stack; in my opinion & experience, they do live up to the hype for a broad range of problems.

    - Peter
    [ September 03, 2004: Message edited by: Peter den Haan ]
     
    jQuery in Action, 2nd edition
     
    subject: Learning Hibernate & Spring
     
    Similar Threads
    GRAILS:A Beginner
    What do you do when you are 'On-Bench'?
    Which technology is best to study in parallel
    Job Wanted on Spring3, Struts2 and Hibernate 3 Free Service!!!
    is scwcd worth it?