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 c4d81acaf..40ac59b02 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 @@ -82,95 +82,42 @@ public interface JdbcAggregateOperations { T update(T instance); /** - * Deletes a single Aggregate including all entities contained in that aggregate. - *

- * Since no version attribute is provided this method will never throw a - * {@link org.springframework.dao.OptimisticLockingFailureException}. If no rows match the generated delete operation - * this fact will be silently ignored. - *

+ * Counts the number of aggregates of a given type. * - * @param id the id of the aggregate root of the aggregate to be deleted. Must not be {@code null}. - * @param domainType the type of the aggregate root. - * @param the type of the aggregate root. + * @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}. */ - void deleteById(Object id, Class domainType); + long count(Class domainType); /** - * Deletes all aggregates identified by their aggregate root ids. - *

- * Since no version attribute is provided this method will never throw a - * {@link org.springframework.dao.OptimisticLockingFailureException}. If no rows match the generated delete operation - * this fact will be silently ignored. - *

+ * Counts the number of aggregates of a given type that match the given query. * - * @param ids the ids of the aggregate roots of the aggregates to be deleted. Must not be {@code null}. - * @param domainType the type of the aggregate root. - * @param the type of the aggregate root. + * @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 */ - void deleteAllById(Iterable ids, Class domainType); + long count(Query query, Class domainType); /** - * Delete an aggregate identified by its aggregate root. + * Determine whether there are aggregates that match the {@link Query} * - * @param aggregateRoot to delete. Must not be {@code null}. - * @param the type of the aggregate root. + * @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 */ - void delete(T aggregateRoot); + boolean exists(Query query, Class domainType); /** - * Delete an aggregate identified by its aggregate root. + * Checks if an aggregate identified by type and id exists in the database. * - * @param aggregateRoot to delete. Must not be {@code null}. - * @param domainType the type of the aggregate root. Must not be {@code null}. + * @param id the id of the aggregate root. + * @param domainType the type of the aggregate root. * @param the type of the aggregate root. - * @throws org.springframework.dao.OptimisticLockingFailureException when {@literal T} has a version attribute and the - * version attribute of the provided 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 #delete(Object)} instead - */ - @Deprecated - default void delete(T aggregateRoot, Class domainType) { - delete(aggregateRoot); - } - - /** - * Delete all aggregates of a given type. - * - * @param domainType type of the aggregate roots to be deleted. Must not be {@code null}. - */ - void deleteAll(Class domainType); - - /** - * Delete all aggregates identified by their aggregate roots. - * - * @param aggregateRoots to delete. Must not be {@code null}. - * @param the type of the aggregate roots. - */ - void deleteAll(Iterable aggregateRoots); - - /** - * Delete all aggregates identified by their aggregate roots. - * - * @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. - * @deprecated since 3.0 use {@link #deleteAll(Iterable)} instead. - */ - @Deprecated - 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}. + * @return whether the aggregate exists. */ - long count(Class domainType); + boolean existsById(Object id, Class domainType); /** * Load an aggregate from the database. @@ -202,16 +149,6 @@ public interface JdbcAggregateOperations { */ 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. * @@ -238,53 +175,117 @@ public interface JdbcAggregateOperations { * 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}. + * @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 selectOne(Query query, Class entityClass); + 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 entityClass the entity type 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 select(Query query, Class entityClass); + Iterable findAll(Query query, Class domainType); /** - * Determine whether there are aggregates that match the {@link Query} + * 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}. - * @return {@literal true} if the object exists. + * @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 */ - boolean exists(Query query, Class entityClass); + Page findAll(Query query, Class domainType, Pageable pageable); /** - * Counts the number of aggregates of a given type that match the given query. + * Deletes a single Aggregate including all entities contained in that aggregate. + *

+ * Since no version attribute is provided this method will never throw a + * {@link org.springframework.dao.OptimisticLockingFailureException}. If no rows match the generated delete operation + * this fact will be silently ignored. + *

* - * @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 + * @param id the id of the aggregate root of the aggregate to be deleted. Must not be {@code null}. + * @param domainType the type of the aggregate root. + * @param the type of the aggregate root. */ - long count(Query query, Class entityClass); + void deleteById(Object id, 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. + * Deletes all aggregates identified by their aggregate root ids. + *

+ * Since no version attribute is provided this method will never throw a + * {@link org.springframework.dao.OptimisticLockingFailureException}. If no rows match the generated delete operation + * this fact will be silently ignored. + *

* - * @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 + * @param ids the ids of the aggregate roots of the aggregates to be deleted. Must not be {@code null}. + * @param domainType the type of the aggregate root. + * @param the type of the aggregate root. */ - Page select(Query query, Class entityClass, Pageable pageable); + void deleteAllById(Iterable ids, Class domainType); + + /** + * Delete an aggregate identified by its aggregate root. + * + * @param aggregateRoot to delete. Must not be {@code null}. + * @param the type of the aggregate root. + */ + void delete(T aggregateRoot); + + /** + * Delete an aggregate identified by its aggregate root. + * + * @param aggregateRoot to delete. 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. + * @throws org.springframework.dao.OptimisticLockingFailureException when {@literal T} has a version attribute and the + * version attribute of the provided 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 #delete(Object)} instead + */ + @Deprecated(since = "3.0") + default void delete(T aggregateRoot, Class domainType) { + delete(aggregateRoot); + } + + /** + * Delete all aggregates of a given type. + * + * @param domainType type of the aggregate roots to be deleted. Must not be {@code null}. + */ + void deleteAll(Class domainType); + + /** + * Delete all aggregates identified by their aggregate roots. + * + * @param aggregateRoots to delete. Must not be {@code null}. + * @param the type of the aggregate roots. + */ + void deleteAll(Iterable aggregateRoots); + + /** + * Delete all aggregates identified by their aggregate roots. + * + * @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. + * @deprecated since 3.0 use {@link #deleteAll(Iterable)} instead. + */ + @Deprecated(since = "3.0") + default void deleteAll(Iterable aggregateRoots, Class domainType) { + deleteAll(aggregateRoots); + } } 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 791c7c622..01c4dcf8b 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 @@ -214,25 +214,35 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations { } @Override - public T findById(Object id, Class domainType) { + 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"); - T entity = accessStrategy.findById(id, domainType); - if (entity == null) { - return null; - } - return triggerAfterConvert(entity); + return accessStrategy.existsById(id, domainType); } @Override - public boolean existsById(Object id, Class domainType) { + public T findById(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); + T entity = accessStrategy.findById(id, domainType); + if (entity == null) { + return null; + } + return triggerAfterConvert(entity); } @Override @@ -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); - } - - @Override - public long count(Query query, Class entityClass) { - return accessStrategy.count(query, entityClass); - } + public Page findAll(Query query, Class domainType, Pageable pageable) { - @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 43d6f41e4..9b6e052b0 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 927ab4136..a2a67c16c 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); - - /** - * 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); + Iterable findAll(Query query, Class domainType, Pageable pageable); - /** - * 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 df8caec59..76bff41d6 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 f116ed2e7..6261f0d73 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 803d2b246..d1b75f1ce 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 3a0911694..a3e3fb01d 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