spring-projects / spring-projects/spring-data-relational
Make the DataAccessStrategy a Spring Plugin [DATAJDBC-139]
Open
@schauder is already working on this.
Since Dec 31, 2020.
type: enhancement
- Dominant language
- Java
- Stars
- 827
- Forks
- 394
- PR merge metrics
- No merged PRs in 30d
Description
Jens Schauder opened DATAJDBC-139 and commented
Configuration could then look similar to this:
@Configuration
@EnableJdbcRepositories
class Config {
@Bean
Whatever foo(WhateverRegistry registry) {
registry.withCustomizedDefault(Class<?> domainType, Function<DDAS, DAS> function);
registry.withCustomizedDefault(Customer.class, CustomDAS.class)
registry.withCustomizedDefault(Object.class, CustomDAS::new);
registry.withCustomizedDefault(Customer.class, defaultDAS -> new CustomDAS(defaultDAS));
registry.withDataAccess(Object.class, new MyCustomDefaultDataAccessStrategy(…));
registry.withDataAccess(Customer.class, new JooqDataAccessStrategy());
}
@Bean
DataAccStrategy customerDAS() {
return new JooqDAS(Customer.class) //
.…;
}
}
class CustomDAS extends DelegatingDAS {
findById(ID id, Class<?> domainType) {
if (Foo.class.)
}
}
interface DAS extends Plugin<Delimiter> {
boolean supports(Delimiter delimiter);
}
abstract class TypeBasedDataAccess implements DAS {
private final Class<?> supportedDomainType;
boolean supports(Delimiter delimiter) {
return delimiter.matches(supportedDomainType);
}
}
interface OrderRepository extends CrudRepository<Order, Long> {}
interface CustomerRepository extends CrudRepository<Customer, Long> {}
No further details from DATAJDBC-139
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.