spring-projects / spring-projects/spring-data-relational

Make the DataAccessStrategy a Spring Plugin [DATAJDBC-139]

Open
#372 0 comments 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.