Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementing Persistance with Spring

 
Nitin Tonk
Greenhorn
Posts: 14
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently we are developing a flex UI. The next we have to decide on the Persistance part that can be used.
The application has majorly CRUD operations with large amount of data.
Will using Spring persistance be the best solution.?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will using Spring persistance be the best solution.?

The real question is how do you want to persist your data ? Via JDBC ? Via an ORM framework ? Spring cannot be said to be "the best persistence solution", Spring is only a "facade" which helps you in different ways to persist data, reducing boiler plate code. Except for JDBC, the real persistence is delegated to persistence frameworks like Hibernate. Spring can help you integrate these frameworks, and can also help you manage transactions.
 
Raghu Kasturi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are planning to build a DAO framework using spring that will be a great idea. I have recently implemented Ibatis + Spring in our project and worked really well. Before starting coding evaluate your options Ibatis or Hibernate, and i would suggest have Typed DAO interfaces for all transactions in that way you can either have your implementation in Ibatis / Hibernate / JDBC.
 
Babji Reddy
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While Spring can work well with iBatis and Hibernate, are there any guiding factors to pick one Vs the other.
I hear from other peers that iBatis is more SQL friendly where as Hibernate is more Java code friendly, is this a valid observation. I have used Hibernate but not iBatis. Definitely liked Hibernate but using Hibernate is not by choice but thats what used in the organization.
 
Paul Fisher
author
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While I agree that Spring is really more of an integration framework, it is nevertheless an excellent choice for building a persistence tier. Spring helps to decouple the actual persistence technology, which will help make your application more portable. For instance, if you started building your application using Spring and Hibernate, but later decided to use ibatis, Spring will help to make this migration easier. For instance, Spring provides a generic exception hierarchy that is abstracted from any particular persistence technology, allowing you to handle exceptional conditions, but in a framework-agnostic way.

One of the more alluring features of Spring is its declarative transaction support, allowing you to define transactional rules for your application without having to write lots of boilerplate code. Instead, you can apply annotations to your service layer classes to define the transactional semantics — even to declare granular rules about what exceptions may or may not trigger a rollback.

Additionally, because Spring helps you to keep your code decoupled, it facilitates testing, and even provides some convenience classes for integration testing.

In my experience, I've found Spring and Hibernate to be an amazing combination, and there's lots of evidence to support this — just look at the new frameworks built on top of Spring and Hibernate, such as grails and roo, among others!

Thanks,

Paul Tepper Fisher, author Spring Persistence with Hibernate
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Fisher wrote:One of the more alluring features of Spring is its declarative transaction support, allowing you to define transactional rules for your application without having to write lots of boilerplate code.

+1. And it is extra easy to pick up if you already have some knowledge about EJB transaction management, where the transaction propagation rules are very similar.
 
Nitin Tonk
Greenhorn
Posts: 14
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everybody for the valuable feedback.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic