While trying to understand the purpose of 'Spring Data' i came across this article and tried few examples with Gemfire/ Redis repositories and their corresponding Spring-Data components. Could someone help me with the following questions.
Scenario: When GemFire was my datastore, i had to use methods create, get and remove on the GemFireTemplate to perform the CRUD operations. When Redis was my datastore, I had to use methods .opsForHash().put , .opsForHash().get and .opsForHash().delete on the RedisTemplate to perform the same CRUD operations.
Isn't Spring-Data supposed to provide a level of abstraction to the underlying data store ? If i am expected to know the respective CRUD methods and have different APIs based on the underlying data store, what kind of abstraction does Spring-Data components bring in ? Can't I directly use a Jedis or Java client for Gemfire to perform these datatstore specific CRUD operations ?
This link seems to explain that but, looks like i need some help in understanding it.
there is no general API to all the persistence stores. The differences are too fundamental. But the Spring Data project does provide a common programming model to access your data
Best How To :
Spring data does provide a level of abstraction to the underlying data store. However, NoSQL stores are a very diverse spectrum, one is a graph database, the other is specialized for storing documents, the third for storing key-value pairs etc. Nonetheless, these are not the differences that you want to abstract away, these are the unique feature that made you choose them in the first place.
On the other hand, Spring Data gives you consistency and means to apply the known patterns against these different store
- It gives you a consisent way to configure resources for accessing the stores
- Mapping and conversion between the underlying types and Java types
- A repository abstraction for most of the stores that boils down to only declaring the interface for the basic CRUD operation. The implementation and the store-specific stuff is handled by Spring Data
- Dedicate Template implementation that provide callbacks for accessing native APIs
The list goes on. The point is that Spring Data does provide a level of abstraction as much as it is possible, but it also doesn't restrict the exposed functionality to a least known common denominator as that would take away the benefits of the different stores.