Browse Source

Polishing.

See spring-projects/spring-data-jdbc/issues/1041
Original pull request spring-projects/spring-data-r2dbc/pull/720
pull/1188/head
Jens Schauder 4 years ago
parent
commit
56ece619d2
No known key found for this signature in database
GPG Key ID: 45CC872F17423DBF
  1. 8
      spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/StatementMapper.java
  2. 4
      spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/dialect/H2Dialect.java
  3. 11
      spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryCreator.java
  4. 36
      spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/AbstractR2dbcRepositoryIntegrationTests.java
  5. 92
      spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/query/PartTreeR2dbcQueryUnitTests.java

8
spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/StatementMapper.java

@ -15,7 +15,13 @@ @@ -15,7 +15,13 @@
*/
package org.springframework.data.r2dbc.core;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Supplier;
import java.util.stream.Collectors;

4
spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/dialect/H2Dialect.java

@ -23,10 +23,6 @@ public class H2Dialect extends PostgresDialect { @@ -23,10 +23,6 @@ public class H2Dialect extends PostgresDialect {
return identifier.getReference(getIdentifierProcessing());
}
/*
* (non-Javadoc)
* @see org.springframework.data.relational.core.dialect.Dialect#lock()
*/
@Override
public LockClause lock() {
// H2 Dialect does not support the same lock keywords as PostgreSQL, but it supports the ANSI SQL standard.

11
spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryCreator.java

@ -158,14 +158,16 @@ class R2dbcQueryCreator extends RelationalQueryCreator<PreparedOperation<?>> { @@ -158,14 +158,16 @@ class R2dbcQueryCreator extends RelationalQueryCreator<PreparedOperation<?>> {
for (String projectedProperty : projectedProperties) {
RelationalPersistentProperty property = entity.getPersistentProperty(projectedProperty);
Column column = table
.column(property != null ? property.getColumnName() : SqlIdentifier.unquoted(projectedProperty));
Column column = table.column(property != null //
? property.getColumnName() //
: SqlIdentifier.unquoted(projectedProperty));
expressions.add(column);
}
} else if (tree.isExistsProjection()) {
expressions = dataAccessStrategy.getIdentifierColumns(entityToRead).stream().map(table::column)
expressions = dataAccessStrategy.getIdentifierColumns(entityToRead).stream() //
.map(table::column) //
.collect(Collectors.toList());
} else if (tree.isCountProjection()) {
@ -175,7 +177,8 @@ class R2dbcQueryCreator extends RelationalQueryCreator<PreparedOperation<?>> { @@ -175,7 +177,8 @@ class R2dbcQueryCreator extends RelationalQueryCreator<PreparedOperation<?>> {
expressions = Collections.singletonList(Functions.count(countExpression));
} else {
expressions = dataAccessStrategy.getAllColumns(entityToRead).stream().map(table::column)
expressions = dataAccessStrategy.getAllColumns(entityToRead).stream() //
.map(table::column) //
.collect(Collectors.toList());
}

36
spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/AbstractR2dbcRepositoryIntegrationTests.java

@ -112,7 +112,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -112,7 +112,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
protected abstract Class<? extends LegoSetRepository> getRepositoryInterfaceType();
@Test
@Test // GH-2
void shouldInsertNewItems() {
LegoSet legoSet1 = new LegoSet(null, "SCHAUFELRADBAGGER", 12, true);
@ -124,7 +124,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -124,7 +124,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete();
}
@Test
@Test // GH-2
void shouldFindItemsByManual() {
shouldInsertNewItems();
@ -137,7 +137,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -137,7 +137,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete();
}
@Test
@Test // GH-2
void shouldFindItemsByNameContains() {
shouldInsertNewItems();
@ -151,7 +151,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -151,7 +151,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
}).verifyComplete();
}
@Test // gh-475, gh-607
@Test // GH-475, GH-607
void shouldFindApplyingInterfaceProjection() {
shouldInsertNewItems();
@ -173,7 +173,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -173,7 +173,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
}).verifyComplete();
}
@Test // gh-475
@Test // GH-475
void shouldByStringQueryApplyingDtoProjection() {
shouldInsertNewItems();
@ -187,7 +187,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -187,7 +187,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
}).verifyComplete();
}
@Test // gh-344
@Test // GH-344
void shouldFindApplyingDistinctProjection() {
LegoSet legoSet1 = new LegoSet(null, "SCHAUFELRADBAGGER", 12, true);
@ -207,7 +207,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -207,7 +207,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
}).verifyComplete();
}
@Test // gh-41
@Test // GH-41
void shouldFindApplyingSimpleTypeProjection() {
shouldInsertNewItems();
@ -220,7 +220,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -220,7 +220,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
}).verifyComplete();
}
@Test // gh-698
@Test // GH-698
void shouldBeTrue() {
shouldInsertNewItems();
@ -246,7 +246,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -246,7 +246,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
assertThat(getCount(count)).satisfies(numberOf(1));
}
@Test // gh-335
@Test // GH-335
void shouldFindByPageable() {
Flux<LegoSet> sets = Flux.fromStream(IntStream.range(0, 100).mapToObj(value -> {
@ -275,7 +275,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -275,7 +275,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
}).verifyComplete();
}
@Test // gh-335
@Test // GH-335
void shouldFindTop10() {
Flux<LegoSet> sets = Flux
@ -292,7 +292,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -292,7 +292,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete();
}
@Test // gh-341
@Test // GH-341
void shouldDeleteAll() {
shouldInsertNewItems();
@ -306,7 +306,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -306,7 +306,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete();
}
@Test
@Test // GH-2
public void shouldInsertItemsTransactional() {
R2dbcTransactionManager r2dbcTransactionManager = new R2dbcTransactionManager(connectionFactory);
@ -330,7 +330,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -330,7 +330,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
assertThat(getCount(map)).satisfies(numberOf(2));
}
@Test // gh-363
@Test // GH-363
void derivedQueryWithCountProjection() {
shouldInsertNewItems();
@ -341,7 +341,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -341,7 +341,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete();
}
@Test // gh-363
@Test // GH-363
void derivedQueryWithCount() {
shouldInsertNewItems();
@ -352,7 +352,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -352,7 +352,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete();
}
@Test // gh-468
@Test // GH-468
void derivedQueryWithExists() {
shouldInsertNewItems();
@ -368,7 +368,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -368,7 +368,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete();
}
@Test // gh-421
@Test // GH-421
void shouldDeleteAllAndReturnCount() {
shouldInsertNewItems();
@ -383,7 +383,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -383,7 +383,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete();
}
@Test
@Test // GH-1041
void getAllByNameWithWriteLock() {
shouldInsertNewItems();
@ -396,7 +396,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg @@ -396,7 +396,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
.verifyComplete();
}
@Test
@Test // GH-1041
void findByNameAndFlagWithReadLock() {
shouldInsertNewItems();

92
spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/query/PartTreeR2dbcQueryUnitTests.java

@ -102,7 +102,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -102,7 +102,7 @@ class PartTreeR2dbcQueryUnitTests {
dataAccessStrategy);
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByStringAttribute() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstName", String.class);
@ -114,7 +114,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -114,7 +114,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1");
}
@Test // gh-282
@Test // GH-282
void createsQueryWithIsNullCondition() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstName", String.class);
@ -126,7 +126,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -126,7 +126,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name IS NULL");
}
@Test // gh-282
@Test // GH-282
void createsQueryWithLimitForExistsProjection() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("existsByFirstName", String.class);
@ -138,7 +138,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -138,7 +138,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + TABLE + ".id FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1 LIMIT 1");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByTwoStringAttributes() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByLastNameAndFirstName", String.class, String.class);
@ -151,7 +151,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -151,7 +151,7 @@ class PartTreeR2dbcQueryUnitTests {
+ ".last_name = $1 AND (" + TABLE + ".first_name = $2)");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByOneOfTwoStringAttributes() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByLastNameOrFirstName", String.class, String.class);
@ -164,7 +164,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -164,7 +164,7 @@ class PartTreeR2dbcQueryUnitTests {
+ ".last_name = $1 OR (" + TABLE + ".first_name = $2)");
}
@Test // gh-282, gh-349
@Test // GH-282, gh-349
void createsQueryToFindAllEntitiesByDateAttributeBetween() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthBetween", Date.class, Date.class);
@ -185,7 +185,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -185,7 +185,7 @@ class PartTreeR2dbcQueryUnitTests {
verify(bindTarget, times(1)).bind(1, to);
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeLessThan() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeLessThan", Integer.class);
@ -198,7 +198,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -198,7 +198,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age < $1");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeLessThanEqual() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeLessThanEqual", Integer.class);
@ -211,7 +211,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -211,7 +211,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age <= $1");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeGreaterThan() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeGreaterThan", Integer.class);
@ -224,7 +224,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -224,7 +224,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age > $1");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeGreaterThanEqual() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeGreaterThanEqual", Integer.class);
@ -237,7 +237,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -237,7 +237,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age >= $1");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByDateAttributeAfter() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthAfter", Date.class);
@ -250,7 +250,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -250,7 +250,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".date_of_birth > $1");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByDateAttributeBefore() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByDateOfBirthBefore", Date.class);
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter,
@ -262,7 +262,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -262,7 +262,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".date_of_birth < $1");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeIsNull() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeIsNull");
@ -275,7 +275,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -275,7 +275,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age IS NULL");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeIsNotNull() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeIsNotNull");
@ -288,7 +288,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -288,7 +288,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age IS NOT NULL");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeLike() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameLike", String.class);
@ -301,7 +301,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -301,7 +301,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name LIKE $1");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeNotLike() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameNotLike", String.class);
@ -314,7 +314,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -314,7 +314,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name NOT LIKE $1");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeStartingWith() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameStartingWith", String.class);
@ -327,7 +327,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -327,7 +327,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name LIKE $1");
}
@Test // gh-282
@Test // GH-282
void appendsLikeOperatorParameterWithPercentSymbolForStartingWithQuery() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameStartingWith", String.class);
@ -341,7 +341,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -341,7 +341,7 @@ class PartTreeR2dbcQueryUnitTests {
verify(bindTarget, times(1)).bind(0, "Jo%");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeEndingWith() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameEndingWith", String.class);
@ -354,7 +354,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -354,7 +354,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name LIKE $1");
}
@Test // gh-282
@Test // GH-282
void prependsLikeOperatorParameterWithPercentSymbolForEndingWithQuery() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameEndingWith", String.class);
@ -368,7 +368,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -368,7 +368,7 @@ class PartTreeR2dbcQueryUnitTests {
verify(bindTarget, times(1)).bind(0, "%hn");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeContaining() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameContaining", String.class);
@ -381,7 +381,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -381,7 +381,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name LIKE $1");
}
@Test // gh-282
@Test // GH-282
void wrapsLikeOperatorParameterWithPercentSymbolsForContainingQuery() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameContaining", String.class);
@ -395,7 +395,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -395,7 +395,7 @@ class PartTreeR2dbcQueryUnitTests {
verify(bindTarget, times(1)).bind(0, "%oh%");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeNotContaining() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameNotContaining", String.class);
@ -408,7 +408,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -408,7 +408,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name NOT LIKE $1");
}
@Test // gh-282
@Test // GH-282
void wrapsLikeOperatorParameterWithPercentSymbolsForNotContainingQuery() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameNotContaining", String.class);
@ -422,7 +422,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -422,7 +422,7 @@ class PartTreeR2dbcQueryUnitTests {
verify(bindTarget, times(1)).bind(0, "%oh%");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeWithDescendingOrderingByStringAttribute()
throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeOrderByLastNameDesc", Integer.class);
@ -436,7 +436,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -436,7 +436,7 @@ class PartTreeR2dbcQueryUnitTests {
"SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age = $1 ORDER BY users.last_name DESC");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeWithAscendingOrderingByStringAttribute() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeOrderByLastNameAsc", Integer.class);
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter,
@ -449,7 +449,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -449,7 +449,7 @@ class PartTreeR2dbcQueryUnitTests {
"SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age = $1 ORDER BY users.last_name ASC");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeNot() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByLastNameNot", String.class);
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter,
@ -461,7 +461,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -461,7 +461,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".last_name != $1");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeIn() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeIn", Collection.class);
@ -475,7 +475,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -475,7 +475,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age IN ($1)");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByIntegerAttributeNotIn() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByAgeNotIn", Collection.class);
PartTreeR2dbcQuery r2dbcQuery = new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter,
@ -488,7 +488,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -488,7 +488,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".age NOT IN ($1)");
}
@Test // gh-282, gh-698
@Test // GH-282, gh-698
void createsQueryToFindAllEntitiesByBooleanAttributeTrue() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByActiveTrue");
@ -501,7 +501,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -501,7 +501,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".active = $1");
}
@Test // gh-282, gh-698
@Test // GH-282, gh-698
void createsQueryToFindAllEntitiesByBooleanAttributeFalse() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByActiveFalse");
@ -514,7 +514,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -514,7 +514,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".active = $1");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindAllEntitiesByStringAttributeIgnoringCase() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameIgnoreCase", String.class);
@ -527,7 +527,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -527,7 +527,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE UPPER(" + TABLE + ".first_name) = UPPER($1)");
}
@Test // gh-282
@Test // GH-282
void throwsExceptionWhenIgnoringCaseIsImpossible() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findByIdIgnoringCase", Long.class);
@ -538,7 +538,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -538,7 +538,7 @@ class PartTreeR2dbcQueryUnitTests {
.isThrownBy(() -> createQuery(r2dbcQuery, getAccessor(queryMethod, new Object[] { 1L })));
}
@Test // gh-282
@Test // GH-282
void throwsExceptionWhenInPredicateHasNonIterableParameter() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByIdIn", Long.class);
@ -547,7 +547,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -547,7 +547,7 @@ class PartTreeR2dbcQueryUnitTests {
.isThrownBy(() -> new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter, dataAccessStrategy));
}
@Test // gh-282
@Test // GH-282
void throwsExceptionWhenSimplePropertyPredicateHasIterableParameter() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllById", Collection.class);
@ -556,7 +556,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -556,7 +556,7 @@ class PartTreeR2dbcQueryUnitTests {
.isThrownBy(() -> new PartTreeR2dbcQuery(queryMethod, operations, r2dbcConverter, dataAccessStrategy));
}
@Test // gh-282
@Test // GH-282
void throwsExceptionWhenConditionKeywordIsUnsupported() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByIdIsEmpty");
@ -567,7 +567,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -567,7 +567,7 @@ class PartTreeR2dbcQueryUnitTests {
.isThrownBy(() -> createQuery(r2dbcQuery, getAccessor(queryMethod, new Object[0])));
}
@Test // gh-282
@Test // GH-282
void throwsExceptionWhenInvalidNumberOfParameterIsGiven() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstName", String.class);
@ -578,7 +578,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -578,7 +578,7 @@ class PartTreeR2dbcQueryUnitTests {
.isThrownBy(() -> createQuery(r2dbcQuery, getAccessor(queryMethod, new Object[0])));
}
@Test // gh-282
@Test // GH-282
void createsQueryWithLimitToFindEntitiesByStringAttribute() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findTop3ByFirstName", String.class);
@ -591,7 +591,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -591,7 +591,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1 LIMIT 3");
}
@Test // gh-282
@Test // GH-282
void createsQueryToFindFirstEntityByStringAttribute() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findFirstByFirstName", String.class);
@ -604,7 +604,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -604,7 +604,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT " + ALL_FIELDS + " FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1 LIMIT 1");
}
@Test // gh-341
@Test // GH-341
void createsQueryToDeleteByFirstName() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("deleteByFirstName", String.class);
@ -616,7 +616,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -616,7 +616,7 @@ class PartTreeR2dbcQueryUnitTests {
assertThat(preparedOperation.get()).isEqualTo("DELETE FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1");
}
@Test // gh-344
@Test // GH-344
void createsQueryToFindAllEntitiesByStringAttributeWithDistinct() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findDistinctByFirstName", String.class);
@ -628,7 +628,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -628,7 +628,7 @@ class PartTreeR2dbcQueryUnitTests {
+ ".foo FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1");
}
@Test // gh-475
@Test // GH-475
void createsQueryToFindByOpenProjection() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findOpenProjectionBy");
@ -641,7 +641,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -641,7 +641,7 @@ class PartTreeR2dbcQueryUnitTests {
+ TABLE);
}
@Test // gh-475
@Test // GH-475
void createsDtoProjectionQuery() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAsDtoProjectionBy");
@ -654,7 +654,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -654,7 +654,7 @@ class PartTreeR2dbcQueryUnitTests {
+ TABLE);
}
@Test // gh-363
@Test // GH-363
void createsQueryForCountProjection() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("countByFirstName", String.class);
@ -666,7 +666,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -666,7 +666,7 @@ class PartTreeR2dbcQueryUnitTests {
.isEqualTo("SELECT COUNT(users.id) FROM " + TABLE + " WHERE " + TABLE + ".first_name = $1");
}
@Test // gh-1041
@Test // GH-1041
void createQueryWithPessimisticWriteLock() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameAndLastName", String.class, String.class);
@ -681,7 +681,7 @@ class PartTreeR2dbcQueryUnitTests { @@ -681,7 +681,7 @@ class PartTreeR2dbcQueryUnitTests {
"SELECT users.id, users.first_name, users.last_name, users.date_of_birth, users.age, users.active FROM users WHERE users.first_name = $1 AND (users.last_name = $2) FOR UPDATE OF users");
}
@Test // gh-1041
@Test // GH-1041
void createQueryWithPessimisticReadLock() throws Exception {
R2dbcQueryMethod queryMethod = getQueryMethod("findAllByFirstNameAndAge", String.class, Integer.class);

Loading…
Cancel
Save