Java – Spring vs Hibernate

hibernatejavaspring

Just trying to get my head round Spring and figuring out how I wire up an Oracle connection in xml config file, and now find out I need yet another framework! – Hibernate, this is soooo frustrating as it feels like I'm getting deeper and deeper into more and more frameworks without actually getting what I need done!

I looked at Hibernate and it seems to do similar things to Spring, bearing in mind I just want to do some SQL inserts in Oracle.

I am reluctant and do not have time to learn 2 frameworks – could I get away with just adopting Hibernate for the simple things I need to do?

Best Answer

...could I get away with just adopting Hibernate for the simple things I need to do?

Yes

Hibernate is for ORM ( object relational mapping ) that is, make your objects persistent to a RDBMS.

Spring goes further. It may be used also as a AOP, Dependency Injector, a Web Application and ORM among other things.

So if you only need ORM, just use Hibernate. Time will come when you need Spring, and you will learn it then.

Here's an architectural view of Spring:

spring

And this is Hibernate:

hibernate