Browse Source

DATAMONGO-1403 - Add maxExecutionTimeMs alias for @Meta(maxExcecutionTime).

We added maxExecutionTimeMs as an alias for maxExcecutionTime which has been deprecated due to spelling issues.

Original pull request: #356.
pull/361/merge
Mark Paluch 10 years ago committed by Christoph Strobl
parent
commit
13a52b5ac9
  1. 21
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Meta.java
  2. 21
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/query/MongoQueryMethodUnitTests.java

21
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Meta.java

@ -21,6 +21,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
import org.springframework.data.annotation.QueryAnnotation; import org.springframework.data.annotation.QueryAnnotation;
/** /**
@ -36,28 +37,40 @@ public @interface Meta {
/** /**
* Set the maximum time limit in milliseconds for processing operations. * Set the maximum time limit in milliseconds for processing operations.
* *
* @deprecated since 1.10 because of spelling issues. Please use {@link #maxExecutionTimeMs()} instead.
* @return * @return
*/ */
@AliasFor("maxExecutionTimeMs")
@Deprecated
long maxExcecutionTime() default -1; long maxExcecutionTime() default -1;
/**
* Set the maximum time limit in milliseconds for processing operations.
*
* @return
* @since 1.10
*/
@AliasFor("maxExcecutionTime")
long maxExecutionTimeMs() default -1;
/** /**
* Only scan the specified number of documents. * Only scan the specified number of documents.
* *
* @return * @return
*/ */
long maxScanDocuments() default -1; long maxScanDocuments() default -1;
/** /**
* Add a comment to the query. * Add a comment to the query.
* *
* @return * @return
*/ */
String comment() default ""; String comment() default "";
/** /**
* Using snapshot prevents the cursor from returning a document more than once. * Using snapshot prevents the cursor from returning a document more than once.
* *
* @return * @return
*/ */
boolean snapshot() default false; boolean snapshot() default false;

21
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/query/MongoQueryMethodUnitTests.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2015 the original author or authors. * Copyright 2011-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -43,9 +43,10 @@ import org.springframework.data.repository.core.support.DefaultRepositoryMetadat
/** /**
* Unit test for {@link MongoQueryMethod}. * Unit test for {@link MongoQueryMethod}.
* *
* @author Oliver Gierke * @author Oliver Gierke
* @author Christoph Strobl * @author Christoph Strobl
* @author Mark Paluch
*/ */
public class MongoQueryMethodUnitTests { public class MongoQueryMethodUnitTests {
@ -151,6 +152,19 @@ public class MongoQueryMethodUnitTests {
assertThat(method.getQueryMetaAttributes().getMaxTimeMsec(), is(100L)); assertThat(method.getQueryMetaAttributes().getMaxTimeMsec(), is(100L));
} }
/**
* @see DATAMONGO-1403
*/
@Test
public void createsMongoQueryMethodWithSpellFixedMaxExecutionTimeCorrectly() throws Exception {
MongoQueryMethod method = queryMethod(PersonRepository.class, "metaWithSpellFixedMaxExecutionTime");
assertThat(method.hasQueryMetaAttributes(), is(true));
assertThat(method.getQueryMetaAttributes().getMaxTimeMsec(), is(100L));
}
/** /**
* @see DATAMONGO-957 * @see DATAMONGO-957
*/ */
@ -224,6 +238,9 @@ public class MongoQueryMethodUnitTests {
@Meta(maxExcecutionTime = 100) @Meta(maxExcecutionTime = 100)
List<User> metaWithMaxExecutionTime(); List<User> metaWithMaxExecutionTime();
@Meta(maxExecutionTimeMs = 100)
List<User> metaWithSpellFixedMaxExecutionTime();
@Meta(maxScanDocuments = 10) @Meta(maxScanDocuments = 10)
List<User> metaWithMaxScan(); List<User> metaWithMaxScan();

Loading…
Cancel
Save