diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Count.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/CountQuery.java similarity index 89% rename from spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Count.java rename to spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/CountQuery.java index b3b7aff69..c3341f309 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Count.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/CountQuery.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 the original author or authors. + * Copyright 2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,27 +20,26 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import org.springframework.core.annotation.AliasFor; /** * Annotation to declare finder count queries directly on repository methods. Both attributes allow using a placeholder * notation of {@code ?0}, {@code ?1} and so on. * - * @see DATAMONGO-1539 - * * @author Fırat KÜÇÜK + * @author Oliver Gierke + * @since 1.10 */ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE }) @Documented @Query(count = true) -public @interface Count { +public @interface CountQuery { /** * Takes a MongoDB JSON string to define the actual query to be executed. This one will take precedence over the - * method name then. - * - * Alias for {@link Query#value}. + * method name then. Alias for {@link Query#value}. * * @return */ diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Delete.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/DeleteQuery.java similarity index 88% rename from spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Delete.java rename to spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/DeleteQuery.java index 7c3de4bbd..d33a18e95 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Delete.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/DeleteQuery.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2016 the original author or authors. + * Copyright 2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,27 +20,26 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import org.springframework.core.annotation.AliasFor; /** * Annotation to declare finder delete queries directly on repository methods. Both attributes allow using a placeholder * notation of {@code ?0}, {@code ?1} and so on. * - * @see DATAMONGO-1539 - * * @author Fırat KÜÇÜK + * @author Oliver Gierke + * @since 1.10 */ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE }) @Documented @Query(delete = true) -public @interface Delete { +public @interface DeleteQuery { /** * Takes a MongoDB JSON string to define the actual query to be executed. This one will take precedence over the - * method name then. - * - * Alias for {@link Query#value}. + * method name then. Alias for {@link Query#value}. * * @return */ diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/AbstractPersonRepositoryIntegrationTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/AbstractPersonRepositoryIntegrationTests.java index 470a99054..21401a649 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/AbstractPersonRepositoryIntegrationTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/AbstractPersonRepositoryIntegrationTests.java @@ -1311,22 +1311,19 @@ public abstract class AbstractPersonRepositoryIntegrationTests { /** * @see DATAMONGO-1539 */ - @Test - public void countsPersonsByFirstname() { - - long result = repository.countByThePersonsFirstname("Dave"); - assertThat(result, is(1L)); - } + @Test + public void countsPersonsByFirstname() { + assertThat(repository.countByThePersonsFirstname("Dave"), is(1L)); + } /** * @see DATAMONGO-1539 */ @Test - public void deletesPersonsByFirstname() { + public void deletesPersonsByFirstname() { - repository.deleteByThePersonsFirstname("Dave"); + repository.deleteByThePersonsFirstname("Dave"); - long result = repository.countByThePersonsFirstname("Dave"); - assertThat(result, is(0L)); - } + assertThat(repository.countByThePersonsFirstname("Dave"), is(0L)); + } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/PersonRepository.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/PersonRepository.java index fe98a3f69..52081b67f 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/PersonRepository.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/PersonRepository.java @@ -370,25 +370,23 @@ public interface PersonRepository extends MongoRepository, Query List findWithSpelByFirstnameForSpELExpressionWithParameterVariableOnly(@Param("firstname") String firstname); /** - * Returns the count of {@link Person} with the given firstname. Uses {@link Count} annotation to define the query - * to be executed. + * Returns the count of {@link Person} with the given firstname. Uses {@link CountQuery} annotation to define the + * query to be executed. * * @see DATAMONGO-1539 - * * @param firstname * @return */ - @Count(value = "{ 'firstname' : ?0 }") + @CountQuery("{ 'firstname' : ?0 }") long countByThePersonsFirstname(String firstname); /** - * Deletes {@link Person} entities with the given firstname. Uses {@link Delete} annotation to define the query + * Deletes {@link Person} entities with the given firstname. Uses {@link DeleteQuery} annotation to define the query * to be executed. * * @see DATAMONGO-1539 - * * @param firstname */ - @Delete(value = "{ 'firstname' : ?0 }") + @DeleteQuery("{ 'firstname' : ?0 }") void deleteByThePersonsFirstname(String firstname); }