aspose file tools*
The moose likes Spring and the fly likes Implementing Persistance with Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Implementing Persistance with Spring" Watch "Implementing Persistance with Spring" New topic
Author

Implementing Persistance with Spring

Nitin Tonk
Greenhorn

Joined: Jun 24, 2008
Posts: 14

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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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.


[My Blog]
All roads lead to JavaRanch
Raghu Kasturi
Greenhorn

Joined: Apr 07, 2008
Posts: 1
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.


Thanks,<br />Raghu
Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
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

Joined: Jul 06, 2010
Posts: 23
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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

Joined: Jun 24, 2008
Posts: 14

Thanks everybody for the valuable feedback.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Implementing Persistance with Spring