Skip to content

Commit b01a34b

Browse files
committed
DATAMONGO-1539 - Polishing.
Renamed @count and @delete to @CountQuery and @deleteQuery. Minor polishing in test cases and test repository methods. JavaDoc, formatting. Original pull request: #416.
1 parent 5650e35 commit b01a34b

File tree

4 files changed

+25
-32
lines changed

4 files changed

+25
-32
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Count.java renamed to spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/CountQuery.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2016 the original author or authors.
2+
* Copyright 2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,27 +20,26 @@
2020
import java.lang.annotation.Retention;
2121
import java.lang.annotation.RetentionPolicy;
2222
import java.lang.annotation.Target;
23+
2324
import org.springframework.core.annotation.AliasFor;
2425

2526
/**
2627
* Annotation to declare finder count queries directly on repository methods. Both attributes allow using a placeholder
2728
* notation of {@code ?0}, {@code ?1} and so on.
2829
*
29-
* @see DATAMONGO-1539
30-
*
3130
* @author Fırat KÜÇÜK
31+
* @author Oliver Gierke
32+
* @since 1.10
3233
*/
3334
@Retention(RetentionPolicy.RUNTIME)
3435
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
3536
@Documented
3637
@Query(count = true)
37-
public @interface Count {
38+
public @interface CountQuery {
3839

3940
/**
4041
* Takes a MongoDB JSON string to define the actual query to be executed. This one will take precedence over the
41-
* method name then.
42-
*
43-
* Alias for {@link Query#value}.
42+
* method name then. Alias for {@link Query#value}.
4443
*
4544
* @return
4645
*/

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Delete.java renamed to spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/DeleteQuery.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2016 the original author or authors.
2+
* Copyright 2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,27 +20,26 @@
2020
import java.lang.annotation.Retention;
2121
import java.lang.annotation.RetentionPolicy;
2222
import java.lang.annotation.Target;
23+
2324
import org.springframework.core.annotation.AliasFor;
2425

2526
/**
2627
* Annotation to declare finder delete queries directly on repository methods. Both attributes allow using a placeholder
2728
* notation of {@code ?0}, {@code ?1} and so on.
2829
*
29-
* @see DATAMONGO-1539
30-
*
3130
* @author Fırat KÜÇÜK
31+
* @author Oliver Gierke
32+
* @since 1.10
3233
*/
3334
@Retention(RetentionPolicy.RUNTIME)
3435
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
3536
@Documented
3637
@Query(delete = true)
37-
public @interface Delete {
38+
public @interface DeleteQuery {
3839

3940
/**
4041
* Takes a MongoDB JSON string to define the actual query to be executed. This one will take precedence over the
41-
* method name then.
42-
*
43-
* Alias for {@link Query#value}.
42+
* method name then. Alias for {@link Query#value}.
4443
*
4544
* @return
4645
*/

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/AbstractPersonRepositoryIntegrationTests.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,22 +1311,19 @@ public void findsPersonsByFirstnameNotLike() throws Exception {
13111311
/**
13121312
* @see DATAMONGO-1539
13131313
*/
1314-
@Test
1315-
public void countsPersonsByFirstname() {
1316-
1317-
long result = repository.countByThePersonsFirstname("Dave");
1318-
assertThat(result, is(1L));
1319-
}
1314+
@Test
1315+
public void countsPersonsByFirstname() {
1316+
assertThat(repository.countByThePersonsFirstname("Dave"), is(1L));
1317+
}
13201318

13211319
/**
13221320
* @see DATAMONGO-1539
13231321
*/
13241322
@Test
1325-
public void deletesPersonsByFirstname() {
1323+
public void deletesPersonsByFirstname() {
13261324

1327-
repository.deleteByThePersonsFirstname("Dave");
1325+
repository.deleteByThePersonsFirstname("Dave");
13281326

1329-
long result = repository.countByThePersonsFirstname("Dave");
1330-
assertThat(result, is(0L));
1331-
}
1327+
assertThat(repository.countByThePersonsFirstname("Dave"), is(0L));
1328+
}
13321329
}

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/PersonRepository.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -370,25 +370,23 @@ Page<Person> findByCustomQueryLastnameAndAddressStreetInList(String lastname, Li
370370
List<Person> findWithSpelByFirstnameForSpELExpressionWithParameterVariableOnly(@Param("firstname") String firstname);
371371

372372
/**
373-
* Returns the count of {@link Person} with the given firstname. Uses {@link Count} annotation to define the query
374-
* to be executed.
373+
* Returns the count of {@link Person} with the given firstname. Uses {@link CountQuery} annotation to define the
374+
* query to be executed.
375375
*
376376
* @see DATAMONGO-1539
377-
*
378377
* @param firstname
379378
* @return
380379
*/
381-
@Count(value = "{ 'firstname' : ?0 }")
380+
@CountQuery("{ 'firstname' : ?0 }")
382381
long countByThePersonsFirstname(String firstname);
383382

384383
/**
385-
* Deletes {@link Person} entities with the given firstname. Uses {@link Delete} annotation to define the query
384+
* Deletes {@link Person} entities with the given firstname. Uses {@link DeleteQuery} annotation to define the query
386385
* to be executed.
387386
*
388387
* @see DATAMONGO-1539
389-
*
390388
* @param firstname
391389
*/
392-
@Delete(value = "{ 'firstname' : ?0 }")
390+
@DeleteQuery("{ 'firstname' : ?0 }")
393391
void deleteByThePersonsFirstname(String firstname);
394392
}

0 commit comments

Comments
 (0)