Browse Source

DATAJDBC-572 - Polishing.

Reorder methods in EnableJdbcRepositories to match other stores. Reformat code.

Original pull request: #235.
pull/237/head
Mark Paluch 6 years ago
parent
commit
08d71817a9
No known key found for this signature in database
GPG Key ID: 51A00FA751B91849
  1. 35
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositories.java
  2. 2
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryFactory.java
  3. 37
      spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositoriesIntegrationTests.java

35
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositories.java

@ -77,10 +77,17 @@ public @interface EnableJdbcRepositories { @@ -77,10 +77,17 @@ 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;
String repositoryImplementationPostfix() default "Impl";
/**
* Configures the location of where to find the Spring Data named queries properties file. Will default to
* {@code META-INF/jdbc-named-queries.properties}.
*/
String namedQueriesLocation() default "";
/**
* Returns the {@link FactoryBean} class to be used for each repository instance. Defaults to
@ -89,17 +96,17 @@ public @interface EnableJdbcRepositories { @@ -89,17 +96,17 @@ public @interface EnableJdbcRepositories {
Class<?> repositoryFactoryBeanClass() default JdbcRepositoryFactoryBean.class;
/**
* Configures the location of where to find the Spring Data named queries properties file. Will default to
* {@code META-INF/jdbc-named-queries.properties}.
* Configure the repository base class to be used to create repository proxies for this particular configuration.
*
* @since 2.1
*/
String namedQueriesLocation() default "";
Class<?> repositoryBaseClass() default DefaultRepositoryBaseClass.class;
/**
* 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}.
* Configures whether nested repository-interfaces (e.g. defined as inner classes) should be discovered by the
* repositories infrastructure.
*/
String repositoryImplementationPostfix() default "Impl";
boolean considerNestedRepositories() default false;
/**
* Configures the name of the {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations} bean
@ -114,12 +121,4 @@ public @interface EnableJdbcRepositories { @@ -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;
}

2
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryFactory.java

@ -15,7 +15,6 @@ @@ -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; @@ -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;

37
spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositoriesIntegrationTests.java

@ -133,7 +133,7 @@ public class EnableJdbcRepositoriesIntegrationTests { @@ -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 { @@ -168,52 +168,63 @@ public class EnableJdbcRepositoriesIntegrationTests {
}
}
private static class DummyRepositoryBaseClass{
private static class DummyRepositoryBaseClass<T, ID> implements CrudRepository<T, ID> {
DummyRepositoryBaseClass(JdbcAggregateTemplate template, PersistentEntity<?,?> persistentEntity) {
DummyRepositoryBaseClass(JdbcAggregateTemplate template, PersistentEntity<?, ?> persistentEntity) {
}
public Object save(Object o) {
@Override
public <S extends T> S save(S s) {
return null;
}
public Iterable saveAll(Iterable iterable) {
@Override
public <S extends T> Iterable<S> saveAll(Iterable<S> iterable) {
return null;
}
public Optional findById(Object o) {
@Override
public Optional<T> 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<T> findAll() {
return null;
}
public Iterable findAllById(Iterable iterable) {
@Override
public Iterable<T> findAllById(Iterable<ID> 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<? extends T> iterable) {
}
@Override
public void deleteAll() {
}

Loading…
Cancel
Save