diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateOperations.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateOperations.java index c4d81aca..40ac59b0 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateOperations.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateOperations.java @@ -81,6 +81,130 @@ public interface JdbcAggregateOperations { */ T update(T instance); + /** + * Counts the number of aggregates of a given type. + * + * @param domainType the type of the aggregates to be counted. + * @return the number of instances stored in the database. Guaranteed to be not {@code null}. + */ + long count(Class domainType); + + /** + * Counts the number of aggregates of a given type that match the given query. + * + * @param query must not be {@literal null}. + * @param domainType the entity type must not be {@literal null}. + * @return the number of instances stored in the database. Guaranteed to be not {@code null}. + * @since 3.0 + */ + long count(Query query, Class domainType); + + /** + * Determine whether there are aggregates that match the {@link Query} + * + * @param query must not be {@literal null}. + * @param domainType the entity type must not be {@literal null}. + * @return {@literal true} if the object exists. + * @since 3.0 + */ + boolean exists(Query query, Class domainType); + + /** + * Checks if an aggregate identified by type and id exists in the database. + * + * @param id the id of the aggregate root. + * @param domainType the type of the aggregate root. + * @param the type of the aggregate root. + * @return whether the aggregate exists. + */ + boolean existsById(Object id, Class domainType); + + /** + * Load an aggregate from the database. + * + * @param id the id of the aggregate to load. Must not be {@code null}. + * @param domainType the type of the aggregate root. Must not be {@code null}. + * @param the type of the aggregate root. + * @return the loaded aggregate. Might return {@code null}. + */ + @Nullable + T findById(Object id, Class domainType); + + /** + * Load all aggregates of a given type that are identified by the given ids. + * + * @param ids of the aggregate roots identifying the aggregates to load. Must not be {@code null}. + * @param domainType the type of the aggregate roots. Must not be {@code null}. + * @param the type of the aggregate roots. Must not be {@code null}. + * @return Guaranteed to be not {@code null}. + */ + Iterable findAllById(Iterable ids, Class domainType); + + /** + * Load all aggregates of a given type. + * + * @param domainType the type of the aggregate roots. Must not be {@code null}. + * @param the type of the aggregate roots. Must not be {@code null}. + * @return Guaranteed to be not {@code null}. + */ + Iterable findAll(Class domainType); + + /** + * Load all aggregates of a given type, sorted. + * + * @param domainType the type of the aggregate roots. Must not be {@code null}. + * @param the type of the aggregate roots. Must not be {@code null}. + * @param sort the sorting information. Must not be {@code null}. + * @return Guaranteed to be not {@code null}. + * @since 2.0 + */ + Iterable findAll(Class domainType, Sort sort); + + /** + * Load a page of (potentially sorted) aggregates of a given type. + * + * @param domainType the type of the aggregate roots. Must not be {@code null}. + * @param the type of the aggregate roots. Must not be {@code null}. + * @param pageable the pagination information. Must not be {@code null}. + * @return Guaranteed to be not {@code null}. + * @since 2.0 + */ + Page findAll(Class domainType, Pageable pageable); + + /** + * Execute a {@code SELECT} query and convert the resulting item to an entity ensuring exactly one result. + * + * @param query must not be {@literal null}. + * @param domainType the entity type must not be {@literal null}. + * @return exactly one result or {@link Optional#empty()} if no match found. + * @throws org.springframework.dao.IncorrectResultSizeDataAccessException if more than one match found. + * @since 3.0 + */ + Optional findOne(Query query, Class domainType); + + /** + * Execute a {@code SELECT} query and convert the resulting items to a {@link Iterable} that is sorted. + * + * @param query must not be {@literal null}. + * @param domainType the entity type must not be {@literal null}. + * @return a non-null sorted list with all the matching results. + * @throws org.springframework.dao.IncorrectResultSizeDataAccessException if more than one match found. + * @since 3.0 + */ + Iterable findAll(Query query, Class domainType); + + /** + * Returns a {@link Page} of entities matching the given {@link Query}. In case no match could be found, an empty + * {@link Page} is returned. + * + * @param query must not be {@literal null}. + * @param domainType the entity type must not be {@literal null}. + * @param pageable can be null. + * @return a {@link Page} of entities matching the given {@link Example}. + * @since 3.0 + */ + Page findAll(Query query, Class domainType, Pageable pageable); + /** * Deletes a single Aggregate including all entities contained in that aggregate. *

@@ -128,7 +252,7 @@ public interface JdbcAggregateOperations { * there is no aggregate root with matching id. In other cases a NOOP delete is silently ignored. * @deprecated since 3.0 use {@link #delete(Object)} instead */ - @Deprecated + @Deprecated(since = "3.0") default void delete(T aggregateRoot, Class domainType) { delete(aggregateRoot); } @@ -154,137 +278,14 @@ public interface JdbcAggregateOperations { * @param aggregateRoots to delete. Must not be {@code null}. * @param domainType type of the aggregate roots to be deleted. Must not be {@code null}. * @param the type of the aggregate roots. - * @throws org.springframework.dao.OptimisticLockingFailureException when {@literal T} has a version attribute and for at least on entity the - * version attribute of the entity does not match the version attribute in the database, or when - * there is no aggregate root with matching id. In other cases a NOOP delete is silently ignored. + * @throws org.springframework.dao.OptimisticLockingFailureException when {@literal T} has a version attribute and for + * at least on entity the version attribute of the entity does not match the version attribute in the + * database, or when there is no aggregate root with matching id. In other cases a NOOP delete is silently + * ignored. * @deprecated since 3.0 use {@link #deleteAll(Iterable)} instead. */ - @Deprecated + @Deprecated(since = "3.0") default void deleteAll(Iterable aggregateRoots, Class domainType) { deleteAll(aggregateRoots); } - - /** - * Counts the number of aggregates of a given type. - * - * @param domainType the type of the aggregates to be counted. - * @return the number of instances stored in the database. Guaranteed to be not {@code null}. - */ - long count(Class domainType); - - /** - * Load an aggregate from the database. - * - * @param id the id of the aggregate to load. Must not be {@code null}. - * @param domainType the type of the aggregate root. Must not be {@code null}. - * @param the type of the aggregate root. - * @return the loaded aggregate. Might return {@code null}. - */ - @Nullable - T findById(Object id, Class domainType); - - /** - * Load all aggregates of a given type that are identified by the given ids. - * - * @param ids of the aggregate roots identifying the aggregates to load. Must not be {@code null}. - * @param domainType the type of the aggregate roots. Must not be {@code null}. - * @param the type of the aggregate roots. Must not be {@code null}. - * @return Guaranteed to be not {@code null}. - */ - Iterable findAllById(Iterable ids, Class domainType); - - /** - * Load all aggregates of a given type. - * - * @param domainType the type of the aggregate roots. Must not be {@code null}. - * @param the type of the aggregate roots. Must not be {@code null}. - * @return Guaranteed to be not {@code null}. - */ - Iterable findAll(Class domainType); - - /** - * Checks if an aggregate identified by type and id exists in the database. - * - * @param id the id of the aggregate root. - * @param domainType the type of the aggregate root. - * @param the type of the aggregate root. - * @return whether the aggregate exists. - */ - boolean existsById(Object id, Class domainType); - - /** - * Load all aggregates of a given type, sorted. - * - * @param domainType the type of the aggregate roots. Must not be {@code null}. - * @param the type of the aggregate roots. Must not be {@code null}. - * @param sort the sorting information. Must not be {@code null}. - * @return Guaranteed to be not {@code null}. - * @since 2.0 - */ - Iterable findAll(Class domainType, Sort sort); - - /** - * Load a page of (potentially sorted) aggregates of a given type. - * - * @param domainType the type of the aggregate roots. Must not be {@code null}. - * @param the type of the aggregate roots. Must not be {@code null}. - * @param pageable the pagination information. Must not be {@code null}. - * @return Guaranteed to be not {@code null}. - * @since 2.0 - */ - Page findAll(Class domainType, Pageable pageable); - - /** - * Execute a {@code SELECT} query and convert the resulting item to an entity ensuring exactly one result. - * - * @param query must not be {@literal null}. - * @param entityClass the entity type must not be {@literal null}. - * @return exactly one result or {@link Optional#empty()} if no match found. - * @throws org.springframework.dao.IncorrectResultSizeDataAccessException if more than one match found. - * @since 3.0 - */ - Optional selectOne(Query query, Class entityClass); - - /** - * Execute a {@code SELECT} query and convert the resulting items to a {@link Iterable} that is sorted. - * - * @param query must not be {@literal null}. - * @param entityClass the entity type must not be {@literal null}. - * @return a non-null sorted list with all the matching results. - * @throws org.springframework.dao.IncorrectResultSizeDataAccessException if more than one match found. - * @since 3.0 - */ - Iterable select(Query query, Class entityClass); - - /** - * Determine whether there are aggregates that match the {@link Query} - * - * @param query must not be {@literal null}. - * @param entityClass the entity type must not be {@literal null}. - * @return {@literal true} if the object exists. - * @since 3.0 - */ - boolean exists(Query query, Class entityClass); - - /** - * Counts the number of aggregates of a given type that match the given query. - * - * @param query must not be {@literal null}. - * @param entityClass the entity type must not be {@literal null}. - * @return the number of instances stored in the database. Guaranteed to be not {@code null}. - * @since 3.0 - */ - long count(Query query, Class entityClass); - - /** - * Returns a {@link Page} of entities matching the given {@link Query}. In case no match could be found, an empty - * {@link Page} is returned. - * - * @param query must not be {@literal null}. - * @param entityClass the entity type must not be {@literal null}. - * @param pageable can be null. - * @return a {@link Page} of entities matching the given {@link Example}. - * @since 3.0 - */ - Page select(Query query, Class entityClass, Pageable pageable); } diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateTemplate.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateTemplate.java index 791c7c62..01c4dcf8 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateTemplate.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/JdbcAggregateTemplate.java @@ -213,6 +213,25 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations { return accessStrategy.count(domainType); } + @Override + public long count(Query query, Class domainType) { + return accessStrategy.count(query, domainType); + } + + @Override + public boolean exists(Query query, Class domainType) { + return accessStrategy.exists(query, domainType); + } + + @Override + public boolean existsById(Object id, Class domainType) { + + Assert.notNull(id, "Id must not be null"); + Assert.notNull(domainType, "Domain type must not be null"); + + return accessStrategy.existsById(id, domainType); + } + @Override public T findById(Object id, Class domainType) { @@ -226,15 +245,6 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations { return triggerAfterConvert(entity); } - @Override - public boolean existsById(Object id, Class domainType) { - - Assert.notNull(id, "Id must not be null"); - Assert.notNull(domainType, "Domain type must not be null"); - - return accessStrategy.existsById(id, domainType); - } - @Override public Iterable findAll(Class domainType, Sort sort) { @@ -256,32 +266,22 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations { } @Override - public Optional selectOne(Query query, Class entityClass) { - return accessStrategy.selectOne(query, entityClass); + public Optional findOne(Query query, Class domainType) { + return accessStrategy.findOne(query, domainType); } @Override - public Iterable select(Query query, Class entityClass) { - return accessStrategy.select(query, entityClass); + public Iterable findAll(Query query, Class domainType) { + return accessStrategy.findAll(query, domainType); } @Override - public boolean exists(Query query, Class entityClass) { - return accessStrategy.exists(query, entityClass); - } + public Page findAll(Query query, Class domainType, Pageable pageable) { - @Override - public long count(Query query, Class entityClass) { - return accessStrategy.count(query, entityClass); - } - - @Override - public Page select(Query query, Class entityClass, Pageable pageable) { - - Iterable items = triggerAfterConvert(accessStrategy.select(query, entityClass, pageable)); + Iterable items = triggerAfterConvert(accessStrategy.findAll(query, domainType, pageable)); List content = StreamSupport.stream(items.spliterator(), false).collect(Collectors.toList()); - return PageableExecutionUtils.getPage(content, pageable, () -> accessStrategy.count(query, entityClass)); + return PageableExecutionUtils.getPage(content, pageable, () -> accessStrategy.count(query, domainType)); } @Override @@ -373,7 +373,6 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations { private void doDeleteAll(Iterable instances, Class domainType) { - BatchingAggregateChange> batchingAggregateChange = BatchingAggregateChange .forDelete(domainType); Map instancesBeforeExecute = new LinkedHashMap<>(); diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/CascadingDataAccessStrategy.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/CascadingDataAccessStrategy.java index 43d6f41e..9b6e052b 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/CascadingDataAccessStrategy.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/CascadingDataAccessStrategy.java @@ -159,28 +159,28 @@ public class CascadingDataAccessStrategy implements DataAccessStrategy { } @Override - public Optional selectOne(Query query, Class probeType) { - return collect(das -> das.selectOne(query, probeType)); + public Optional findOne(Query query, Class domainType) { + return collect(das -> das.findOne(query, domainType)); } @Override - public Iterable select(Query query, Class probeType) { - return collect(das -> das.select(query, probeType)); + public Iterable findAll(Query query, Class domainType) { + return collect(das -> das.findAll(query, domainType)); } @Override - public Iterable select(Query query, Class probeType, Pageable pageable) { - return collect(das -> das.select(query, probeType, pageable)); + public Iterable findAll(Query query, Class domainType, Pageable pageable) { + return collect(das -> das.findAll(query, domainType, pageable)); } @Override - public boolean exists(Query query, Class probeType) { - return collect(das -> das.exists(query, probeType)); + public boolean exists(Query query, Class domainType) { + return collect(das -> das.exists(query, domainType)); } @Override - public long count(Query query, Class probeType) { - return collect(das -> das.count(query, probeType)); + public long count(Query query, Class domainType) { + return collect(das -> das.count(query, domainType)); } private T collect(Function function) { diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DataAccessStrategy.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DataAccessStrategy.java index 927ab413..a2a67c16 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DataAccessStrategy.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DataAccessStrategy.java @@ -200,6 +200,36 @@ public interface DataAccessStrategy extends RelationResolver { */ long count(Class domainType); + /** + * Counts the rows in the table representing the given probe type, that match the given query. + * + * @param domainType the probe type for which to count the elements. Must not be {@code null}. + * @param query the query which elements have to match. + * @return the count. Guaranteed to be not {@code null}. + * @since 3.0 + */ + long count(Query query, Class domainType); + + /** + * Determine whether there is an aggregate of type domainType that matches the provided {@link Query}. + * + * @param query must not be {@literal null}. + * @param domainType the type of entities. Must not be {@code null}. + * @return {@literal true} if the object exists. + * @since 3.0 + */ + boolean exists(Query query, Class domainType); + + /** + * returns if a row with the given id exists for the given type. + * + * @param id the id of the entity for which to check. Must not be {@code null}. + * @param domainType the type of the entity to check for. Must not be {@code null}. + * @param the type of the entity. + * @return {@code true} if a matching row exists, otherwise {@code false}. + */ + boolean existsById(Object id, Class domainType); + /** * Loads a single entity identified by type and id. * @@ -235,16 +265,6 @@ public interface DataAccessStrategy extends RelationResolver { Iterable findAllByPath(Identifier identifier, PersistentPropertyPath path); - /** - * returns if a row with the given id exists for the given type. - * - * @param id the id of the entity for which to check. Must not be {@code null}. - * @param domainType the type of the entity to check for. Must not be {@code null}. - * @param the type of the entity. - * @return {@code true} if a matching row exists, otherwise {@code false}. - */ - boolean existsById(Object id, Class domainType); - /** * Loads all entities of the given type, sorted. * @@ -271,54 +291,35 @@ public interface DataAccessStrategy extends RelationResolver { * Execute a {@code SELECT} query and convert the resulting item to an entity ensuring exactly one result. * * @param query must not be {@literal null}. - * @param probeType the type of entities. Must not be {@code null}. + * @param domainType the type of entities. Must not be {@code null}. * @return exactly one result or {@link Optional#empty()} if no match found. * @throws org.springframework.dao.IncorrectResultSizeDataAccessException if more than one match found. * @since 3.0 */ - Optional selectOne(Query query, Class probeType); + Optional findOne(Query query, Class domainType); /** * Execute a {@code SELECT} query and convert the resulting items to a {@link Iterable}. * * @param query must not be {@literal null}. - * @param probeType the type of entities. Must not be {@code null}. + * @param domainType the type of entities. Must not be {@code null}. * @return a non-null list with all the matching results. * @throws org.springframework.dao.IncorrectResultSizeDataAccessException if more than one match found. * @since 3.0 */ - Iterable select(Query query, Class probeType); + Iterable findAll(Query query, Class domainType); /** * Execute a {@code SELECT} query and convert the resulting items to a {@link Iterable}. Applies the {@link Pageable} * to the result. * * @param query must not be {@literal null}. - * @param probeType the type of entities. Must not be {@literal null}. + * @param domainType the type of entities. Must not be {@literal null}. * @param pageable the pagination that should be applied. Must not be {@literal null}. * @return a non-null list with all the matching results. * @throws org.springframework.dao.IncorrectResultSizeDataAccessException if more than one match found. * @since 3.0 */ - Iterable select(Query query, Class probeType, Pageable pageable); + Iterable findAll(Query query, Class domainType, Pageable pageable); - /** - * Determine whether there is an aggregate of type probeType that matches the provided {@link Query}. - * - * @param query must not be {@literal null}. - * @param probeType the type of entities. Must not be {@code null}. - * @return {@literal true} if the object exists. - * @since 3.0 - */ - boolean exists(Query query, Class probeType); - - /** - * Counts the rows in the table representing the given probe type, that match the given query. - * - * @param probeType the probe type for which to count the elements. Must not be {@code null}. - * @param query the query which elements have to match. - * @return the count. Guaranteed to be not {@code null}. - * @since 3.0 - */ - long count(Query query, Class probeType); } diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategy.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategy.java index df8caec5..76bff41d 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategy.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategy.java @@ -333,42 +333,42 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy { } @Override - public Optional selectOne(Query query, Class probeType) { + public Optional findOne(Query query, Class domainType) { MapSqlParameterSource parameterSource = new MapSqlParameterSource(); - String sqlQuery = sql(probeType).selectByQuery(query, parameterSource); + String sqlQuery = sql(domainType).selectByQuery(query, parameterSource); try { return Optional.ofNullable( - operations.queryForObject(sqlQuery, parameterSource, getEntityRowMapper(probeType))); + operations.queryForObject(sqlQuery, parameterSource, getEntityRowMapper(domainType))); } catch (EmptyResultDataAccessException e) { return Optional.empty(); } } @Override - public Iterable select(Query query, Class probeType) { + public Iterable findAll(Query query, Class domainType) { MapSqlParameterSource parameterSource = new MapSqlParameterSource(); - String sqlQuery = sql(probeType).selectByQuery(query, parameterSource); + String sqlQuery = sql(domainType).selectByQuery(query, parameterSource); - return operations.query(sqlQuery, parameterSource, getEntityRowMapper(probeType)); + return operations.query(sqlQuery, parameterSource, getEntityRowMapper(domainType)); } @Override - public Iterable select(Query query, Class probeType, Pageable pageable) { + public Iterable findAll(Query query, Class domainType, Pageable pageable) { MapSqlParameterSource parameterSource = new MapSqlParameterSource(); - String sqlQuery = sql(probeType).selectByQuery(query, parameterSource, pageable); + String sqlQuery = sql(domainType).selectByQuery(query, parameterSource, pageable); - return operations.query(sqlQuery, parameterSource, getEntityRowMapper(probeType)); + return operations.query(sqlQuery, parameterSource, getEntityRowMapper(domainType)); } @Override - public boolean exists(Query query, Class probeType) { + public boolean exists(Query query, Class domainType) { MapSqlParameterSource parameterSource = new MapSqlParameterSource(); - String sqlQuery = sql(probeType).existsByQuery(query, parameterSource); + String sqlQuery = sql(domainType).existsByQuery(query, parameterSource); Boolean result = operations.queryForObject(sqlQuery, parameterSource, Boolean.class); @@ -378,10 +378,10 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy { } @Override - public long count(Query query, Class probeType) { + public long count(Query query, Class domainType) { MapSqlParameterSource parameterSource = new MapSqlParameterSource(); - String sqlQuery = sql(probeType).countByQuery(query, parameterSource); + String sqlQuery = sql(domainType).countByQuery(query, parameterSource); Long result = operations.queryForObject(sqlQuery, parameterSource, Long.class); diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DelegatingDataAccessStrategy.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DelegatingDataAccessStrategy.java index f116ed2e..6261f0d7 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DelegatingDataAccessStrategy.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DelegatingDataAccessStrategy.java @@ -154,28 +154,28 @@ public class DelegatingDataAccessStrategy implements DataAccessStrategy { } @Override - public Optional selectOne(Query query, Class probeType) { - return delegate.selectOne(query, probeType); + public Optional findOne(Query query, Class domainType) { + return delegate.findOne(query, domainType); } @Override - public Iterable select(Query query, Class probeType) { - return delegate.select(query, probeType); + public Iterable findAll(Query query, Class domainType) { + return delegate.findAll(query, domainType); } @Override - public Iterable select(Query query, Class probeType, Pageable pageable) { - return delegate.select(query, probeType, pageable); + public Iterable findAll(Query query, Class domainType, Pageable pageable) { + return delegate.findAll(query, domainType, pageable); } @Override - public boolean exists(Query query, Class probeType) { - return delegate.exists(query, probeType); + public boolean exists(Query query, Class domainType) { + return delegate.exists(query, domainType); } @Override - public long count(Query query, Class probeType) { - return delegate.count(query, probeType); + public long count(Query query, Class domainType) { + return delegate.count(query, domainType); } /** diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/FetchableFluentQueryByExample.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/FetchableFluentQueryByExample.java index 803d2b24..d1b75f1c 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/FetchableFluentQueryByExample.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/FetchableFluentQueryByExample.java @@ -58,7 +58,7 @@ class FetchableFluentQueryByExample extends FluentQuerySupport { @Override public R oneValue() { - return this.entityOperations.selectOne(createQuery(), getExampleType()) + return this.entityOperations.findOne(createQuery(), getExampleType()) .map(item -> this.getConversionFunction().apply(item)).get(); } @@ -66,21 +66,21 @@ class FetchableFluentQueryByExample extends FluentQuerySupport { public R firstValue() { return this.getConversionFunction() - .apply(this.entityOperations.select(createQuery().sort(getSort()), getExampleType()).iterator().next()); + .apply(this.entityOperations.findAll(createQuery().sort(getSort()), getExampleType()).iterator().next()); } @Override public List all() { return StreamSupport - .stream(this.entityOperations.select(createQuery().sort(getSort()), getExampleType()).spliterator(), false) + .stream(this.entityOperations.findAll(createQuery().sort(getSort()), getExampleType()).spliterator(), false) .map(item -> this.getConversionFunction().apply(item)).collect(Collectors.toList()); } @Override public Page page(Pageable pageable) { - return this.entityOperations.select(createQuery(p -> p.with(pageable)), getExampleType(), pageable) + return this.entityOperations.findAll(createQuery(p -> p.with(pageable)), getExampleType(), pageable) .map(item -> this.getConversionFunction().apply(item)); } @@ -88,7 +88,7 @@ class FetchableFluentQueryByExample extends FluentQuerySupport { public Stream stream() { return StreamSupport - .stream(this.entityOperations.select(createQuery().sort(getSort()), getExampleType()).spliterator(), false) + .stream(this.entityOperations.findAll(createQuery().sort(getSort()), getExampleType()).spliterator(), false) .map(item -> this.getConversionFunction().apply(item)); } diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/SimpleJdbcRepository.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/SimpleJdbcRepository.java index 3a091169..a3e3fb01 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/SimpleJdbcRepository.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/SimpleJdbcRepository.java @@ -142,7 +142,7 @@ public class SimpleJdbcRepository Assert.notNull(example, "Example must not be null"); - return this.entityOperations.selectOne(this.exampleMapper.getMappedExample(example), example.getProbeType()); + return this.entityOperations.findOne(this.exampleMapper.getMappedExample(example), example.getProbeType()); } @Override @@ -159,7 +159,7 @@ public class SimpleJdbcRepository Assert.notNull(example, "Example must not be null"); Assert.notNull(sort, "Sort must not be null"); - return this.entityOperations.select(this.exampleMapper.getMappedExample(example).sort(sort), + return this.entityOperations.findAll(this.exampleMapper.getMappedExample(example).sort(sort), example.getProbeType()); } @@ -168,7 +168,8 @@ public class SimpleJdbcRepository Assert.notNull(example, "Example must not be null"); - return this.entityOperations.select(this.exampleMapper.getMappedExample(example), example.getProbeType(), pageable); + return this.entityOperations.findAll(this.exampleMapper.getMappedExample(example), example.getProbeType(), + pageable); } @Override