views:

460

answers:

6
+1  Q: 

Spring Framework

What is Spring Framework? What's its contribution to Hibernate?

A: 

There is also a .NET version of Spring.

Glenn
A: 

check this link to get basic of spring framework Spring framework

harshit
+4  A: 

Hibernate is an Object Relational Mapping tool, an alternative to Sun's Entity Beans 2.0. Hibernate has become over the years a "de facto standard" for object persistence in Java and today's JPA API is highly inspired by Hibernate (which can be used as JPA implementation).

Spring is a dependency injection framework which allows you to wire components and to benefits from additional services like declarative transaction management, declarative security, integration with many other frameworks, abstraction layers etc. Spring has been created to ease Enterprise Java applications development and to make it possible without EJBs and a "heavyweight" container. With Spring and Hibernate and e.g. Tomcat, you get a nice Enterprise stack. Spring is a "lightweight" container.

Spring and Hibernate have heavily influenced the way we build Java application and their adoption are the proof of the need for simplification. Despite, I see JEE 5 as Sun's answer to these "non standard" solutions to simplify Java Enterprise development.

So yes, Spring Hibernate are widely used together and Spring offers Hibernate (and JPA) integration but Spring and Hibernate are two different projects with separated board and governance. They have mutual interests but IMO the Hibernate Team manages Hibernate, the Spring Team manages Spring.

Pascal Thivent
A: 

Spring and Hibernate are two separate frameworks that can be used together but other than that have nothing to do with each other.

Hibernate is an Object-Relational mapping tool. It helps developers that want to work with Domain Objects that are tied in to relational database tables. If you use Hibernate, the complexity of tasks such as programmatically connecting to a database or parsing result sets is greatly minimized.

The Spring Framework is one that provides several tools, all based around a small number of core concepts. The most famous of these concepts is dependency injection, which allows for loose coupling of objects which can help make development and testing easier.

Out of the box, Spring provides several tools to help play nicely with other frameworks - and Hibernate is one of them. Although Hibernate is a great tool there is some degree of complexity in regards to writing code that performs Database operations, as well as Exception handling. Spring's Hibernate Template attempts to solve this problem. This is probably what you mean by their "contribution", although from what I've seen the people behind Hibernate are not big fans of this support.

You can use Spring without Hibernate or Hibernate without Spring. You can even have a project that uses Hibernate and Spring but doesn't use the Spring Hibernate Template.

bpapa
+2  A: 

The Spring Framework (http://www.springframework.org) is a development stack for JEE-based application. What started as a dependency injection container has evolved into a POJO-based programming model for enterprise applications, providing commonly used services and abstractions (transaction management, caching, batch processing, etc.) out of the box.

There's no direct relationship to Hibernate (which is a object-relational mapping framework), but within its ORM module, Spring provides an integration layer for it. Among the benefits of using it in conjunction with Hibernate are:

  • Ability to use declarative transaction demarcation (transparently applied via Spring's AOP mechanism)

  • Exception translation for the data access layer (to abstract from the actual persistence technology used to implement the DAO interfaces)

So while Spring does not actually contribute to Hibernate (as far as I know), it works very well with Hibernate and provides some convenient benefits.

springify