Adding new DB support in spring data

Viewed 84

Currently spring data has multiple db support (mysql, cassandra, mongo.. very big list), however i want to add my custom repository from the scratch like adding custom db support in spring data. I don't want to extend any existing repositories, instead I want to create a parallel repository strutcutre for my custom datasource. Looking at current implementation it looks like tedious task. It would be a great if someone could help me with minimal requirement to do this.

1 Answers

You could create a repository annotated bean where you would inject EntityManager or the proper bean that is acting like that, depending on database type that you are using.

@Repository
public class MyCustomRepositoryImpl implements MyCustomRepository {

@Autowired
private EntityManager entityManager;

//the methods that you are going to create.

}

For more details see:

https://docs.spring.io/spring-data/data-commons/docs/1.6.1.RELEASE/reference/html/repositories.html Chapter: 1.3 Custom implementations for Spring Data repositories

Related