Skip to content

Commit 7b2636e

Browse files
committed
DATAMONGO-1403 - Add maxExecutionTimeMs alias for @meta(maxExcecutionTime).
This commit adds the maxExecutionTimeMs alias for maxExcecutionTime and deprecates maxExcecutionTime as it has a typo. Original pull request: #356.
1 parent 16e6171 commit 7b2636e

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.lang.annotation.RetentionPolicy;
2222
import java.lang.annotation.Target;
2323

24+
import org.springframework.core.annotation.AliasFor;
2425
import org.springframework.data.annotation.QueryAnnotation;
2526

2627
/**
@@ -36,28 +37,41 @@
3637

3738
/**
3839
* Set the maximum time limit in milliseconds for processing operations.
39-
*
40+
*
41+
* @deprecated because of spelling issues. Please use {@link #maxExecutionTimeMs()} instead.
4042
* @return
4143
*/
44+
@AliasFor("maxExecutionTimeMs")
45+
@Deprecated
4246
long maxExcecutionTime() default -1;
4347

48+
/**
49+
* Set the maximum time limit in milliseconds for processing operations.
50+
* This is an alias for {@link #maxExcecutionTime()}
51+
*
52+
* @return
53+
* @since 1.10
54+
*/
55+
@AliasFor("maxExcecutionTime")
56+
long maxExecutionTimeMs() default -1;
57+
4458
/**
4559
* Only scan the specified number of documents.
46-
*
60+
*
4761
* @return
4862
*/
4963
long maxScanDocuments() default -1;
5064

5165
/**
5266
* Add a comment to the query.
53-
*
67+
*
5468
* @return
5569
*/
5670
String comment() default "";
5771

5872
/**
5973
* Using snapshot prevents the cursor from returning a document more than once.
60-
*
74+
*
6175
* @return
6276
*/
6377
boolean snapshot() default false;

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2015 the original author or authors.
2+
* Copyright 2011-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.
@@ -43,9 +43,10 @@
4343

4444
/**
4545
* Unit test for {@link MongoQueryMethod}.
46-
*
46+
*
4747
* @author Oliver Gierke
4848
* @author Christoph Strobl
49+
* @author Mark Paluch
4950
*/
5051
public class MongoQueryMethodUnitTests {
5152

@@ -151,6 +152,19 @@ public void createsMongoQueryMethodWithMaxExecutionTimeCorrectly() throws Except
151152
assertThat(method.getQueryMetaAttributes().getMaxTimeMsec(), is(100L));
152153
}
153154

155+
156+
/**
157+
* @see DATAMONGO-1403
158+
*/
159+
@Test
160+
public void createsMongoQueryMethodWithSpellFixedMaxExecutionTimeCorrectly() throws Exception {
161+
162+
MongoQueryMethod method = queryMethod(PersonRepository.class, "metaWithSpellFixedMaxExecutionTime");
163+
164+
assertThat(method.hasQueryMetaAttributes(), is(true));
165+
assertThat(method.getQueryMetaAttributes().getMaxTimeMsec(), is(100L));
166+
}
167+
154168
/**
155169
* @see DATAMONGO-957
156170
*/
@@ -224,6 +238,9 @@ interface PersonRepository extends Repository<User, Long> {
224238
@Meta(maxExcecutionTime = 100)
225239
List<User> metaWithMaxExecutionTime();
226240

241+
@Meta(maxExecutionTimeMs = 100)
242+
List<User> metaWithSpellFixedMaxExecutionTime();
243+
227244
@Meta(maxScanDocuments = 10)
228245
List<User> metaWithMaxScan();
229246

0 commit comments

Comments
 (0)