From 08d71817a9771a64bc4b85867731d83a2dfb42a2 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 13 Jul 2020 16:26:34 +0200 Subject: [PATCH] DATAJDBC-572 - Polishing. Reorder methods in EnableJdbcRepositories to match other stores. Reformat code. Original pull request: #235. --- .../config/EnableJdbcRepositories.java | 41 +++++++++---------- .../support/JdbcRepositoryFactory.java | 2 - ...nableJdbcRepositoriesIntegrationTests.java | 37 +++++++++++------ 3 files changed, 44 insertions(+), 36 deletions(-) diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositories.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositories.java index c2ee8694..3be6b7f7 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositories.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositories.java @@ -77,16 +77,11 @@ public @interface EnableJdbcRepositories { Filter[] excludeFilters() default {}; /** - * Configures whether nested repository-interfaces (e.g. defined as inner classes) should be discovered by the - * repositories infrastructure. + * Returns the postfix to be used when looking up custom repository implementations. Defaults to {@literal Impl}. So + * for a repository named {@code PersonRepository} the corresponding implementation class will be looked up scanning + * for {@code PersonRepositoryImpl}. */ - boolean considerNestedRepositories() default false; - - /** - * Returns the {@link FactoryBean} class to be used for each repository instance. Defaults to - * {@link JdbcRepositoryFactoryBean}. - */ - Class repositoryFactoryBeanClass() default JdbcRepositoryFactoryBean.class; + String repositoryImplementationPostfix() default "Impl"; /** * Configures the location of where to find the Spring Data named queries properties file. Will default to @@ -95,11 +90,23 @@ public @interface EnableJdbcRepositories { String namedQueriesLocation() default ""; /** - * Returns the postfix to be used when looking up custom repository implementations. Defaults to {@literal Impl}. So - * for a repository named {@code PersonRepository} the corresponding implementation class will be looked up scanning - * for {@code PersonRepositoryImpl}. + * Returns the {@link FactoryBean} class to be used for each repository instance. Defaults to + * {@link JdbcRepositoryFactoryBean}. */ - String repositoryImplementationPostfix() default "Impl"; + Class repositoryFactoryBeanClass() default JdbcRepositoryFactoryBean.class; + + /** + * Configure the repository base class to be used to create repository proxies for this particular configuration. + * + * @since 2.1 + */ + Class repositoryBaseClass() default DefaultRepositoryBaseClass.class; + + /** + * Configures whether nested repository-interfaces (e.g. defined as inner classes) should be discovered by the + * repositories infrastructure. + */ + boolean considerNestedRepositories() default false; /** * Configures the name of the {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations} bean @@ -114,12 +121,4 @@ public @interface EnableJdbcRepositories { */ String dataAccessStrategyRef() default ""; - /** - * Configure the repository base class to be used to create repository proxies for this particular configuration. - * - * @return - * @since 2.1 - */ - Class repositoryBaseClass() default DefaultRepositoryBaseClass.class; - } diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryFactory.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryFactory.java index 82b765af..248efc3c 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryFactory.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryFactory.java @@ -15,7 +15,6 @@ */ package org.springframework.data.jdbc.repository.support; -import java.io.Serializable; import java.util.Optional; import org.springframework.context.ApplicationEventPublisher; @@ -27,7 +26,6 @@ import org.springframework.data.mapping.callback.EntityCallbacks; import org.springframework.data.relational.core.dialect.Dialect; import org.springframework.data.relational.core.mapping.RelationalMappingContext; import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; -import org.springframework.data.relational.repository.query.RelationalEntityInformation; import org.springframework.data.repository.core.EntityInformation; import org.springframework.data.repository.core.RepositoryInformation; import org.springframework.data.repository.core.RepositoryMetadata; diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositoriesIntegrationTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositoriesIntegrationTests.java index ffb04b0d..13859305 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositoriesIntegrationTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositoriesIntegrationTests.java @@ -133,7 +133,7 @@ public class EnableJdbcRepositoriesIntegrationTests { @EnableJdbcRepositories(considerNestedRepositories = true, includeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = DummyRepository.class), jdbcOperationsRef = "qualifierJdbcOperations", dataAccessStrategyRef = "qualifierDataAccessStrategy", - repositoryBaseClass = DummyRepositoryBaseClass.class) + repositoryBaseClass = DummyRepositoryBaseClass.class) static class TestConfiguration { @Bean @@ -168,52 +168,63 @@ public class EnableJdbcRepositoriesIntegrationTests { } } - private static class DummyRepositoryBaseClass{ + private static class DummyRepositoryBaseClass implements CrudRepository { - DummyRepositoryBaseClass(JdbcAggregateTemplate template, PersistentEntity persistentEntity) { + DummyRepositoryBaseClass(JdbcAggregateTemplate template, PersistentEntity persistentEntity) { } - public Object save(Object o) { + @Override + public S save(S s) { return null; } - public Iterable saveAll(Iterable iterable) { + @Override + public Iterable saveAll(Iterable iterable) { return null; } - public Optional findById(Object o) { + @Override + public Optional findById(ID id) { return Optional.empty(); } - public boolean existsById(Object o) { + @Override + public boolean existsById(ID id) { return false; } - public Iterable findAll() { + @Override + public Iterable findAll() { return null; } - public Iterable findAllById(Iterable iterable) { + @Override + public Iterable findAllById(Iterable iterable) { return null; } + @Override public long count() { - return 23L; + return 23; } - public void deleteById(Object o) { + @Override + public void deleteById(ID id) { } - public void delete(Object o) { + @Override + public void delete(T t) { } - public void deleteAll(Iterable iterable) { + @Override + public void deleteAll(Iterable iterable) { } + @Override public void deleteAll() { }