8

Currently We have an enterprise application that works with spring and JPA. Today we are planning our next generation server.

We are debating whether to use spring-data in our project? It seems to increase productivity and development times.

Are there any alternatives to spring-data to consider? Why not using spring and JPA alone? What do you suggest?

Bear in mind we are starting to develop from scratch so no constraints are available other than:

  1. we use mysql and mongoDB
  2. we code in java
  3. we will develop client side code in GWT.

Currently we have a layered architecture. We have a Service layer and a manager layer, which takes care for persisting and business logic. Whoever built that didn't see a good reason to insert the third DAO layer.

Vitaly Olegovitch
  • 3,509
  • 6
  • 33
  • 49
Urbanleg
  • 6,252
  • 16
  • 76
  • 139
  • It's not really an answer to your question but I'd be interested to hear what let's you look for alternatives? Usually people move *to* Spring Data to increase productivity but you looking for alternatives seems to indicate you see certain drawbacks. Would you mind updating the question with a few more details on that? – Oliver Drotbohm Oct 10 '13 at 20:57

1 Answers1

3

There are some technical benefits of Spring Data over Spring + JPA, which in a pure SQL environment, I think give Spring Data an advantage:

  • Spring Data uses the same CrudRepository interface for all implementations, so you'll have less effort to switch between JPA to MongoDB
  • Spring Data saves you writing the same methods again and again. You just add the method to the interface and it'll generate it for you (e.g. UserRepository.findByUsername())
  • You can save boilerplate on REST implementations for JPA, MongoDB and others (see http://projects.spring.io/spring-data-rest/)
  • If you wanted to experiment with other persistence or indexing services, then there are Spring Data implementations for both mature and newer technologies such as for Neo4j, Hadoop, Solr, ElasticSearch, fuzzydb.

Given that you use MySQL and MongoDB, I think Spring Data is a strong candidate, as it allows developers to code to a single data access API (Spring Data) instead of two (JPA and the MongoDB Java Client).

Regarding the existing architecture, it sounds as though your manager layer is implementing either a Rich Domain pattern, or Active Record.

Spring Data is in my view very well suited to Rich Domain when combined with injection of services using Spring's @Configurable.

Lastly, I'd say that Spring Data also gives a significant advantage when needing to implement services for things like Spring Security and Spring Social, which use MongoDB or others instead of SQL.

We did this in the fuzzydb sample webapp that can be found here. (Disclaimer: I'm the currently sole recent committer on fuzzydb, and haven't touched it for a number of years, but we did have a live service, www.fridgemountain.com, based on that code, but neglected to promote it)

NealeU
  • 1,264
  • 11
  • 23