Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom spring-data repository backend

I already have a working object storage service, developed in-house - let's call it a database. Now I would like to use spring-data for CRUD operations on it, so that in the future I can easily switch to some conventional database. The question in: how can I implement yet another spring-data repository backend? Any guides, tutorials?

like image 624
milan Avatar asked Nov 23 '13 10:11

milan


People also ask

How to create a custom repository in spring data JPA?

The class design diagram above indicates how we can create a custom repository in Spring Data JPA. We just need to let EmployeeRepository implement the custom interface and define the implementation for the customized repository.

Where to put the @repository annotation in Spring Framework?

You might wonder where we put the @Repository annotation. The answer is at EmployeeRepository interface. We just have to provide the implementation of the customizing repository, other parts let Spring Framework complete. This article will not cover how this feature works under the hook.

What is a DDD style repository?

1. Introduction When modeling a real-world system or process, domain-driven design (DDD) style repositories are a good option. For this very purpose, we can use Spring Data JPA as our data access abstraction layer. If you are new to this concept check out this introductory tutorial to help get you up to speed.


Video Answer


1 Answers

The central piece to look at is the API in the Spring Data Commons module. It effectively provides the foundation for all of the existing store implementations. The support consist of the following aspects:

  • Object-to-store mapping (meta-model and conversion implementation)
  • Repository implementation and DI container configuration support

The best way to get started is by having a look at the MongoDB module for example and mimic the implementation. We're currently working on a developer guide whose work-in-progress version you can find in the Spring Data Commons wiki.

like image 145
Oliver Drotbohm Avatar answered Sep 19 '22 07:09

Oliver Drotbohm