Skip to content

Commit 13a52b5

Browse files
mp911dechristophstrobl
authored andcommitted
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.
1 parent f5cfcda commit 13a52b5

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

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

Lines changed: 17 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,40 @@
3637

3738
/**
3839
* Set the maximum time limit in milliseconds for processing operations.
39-
*
40+
*
41+
* @deprecated since 1.10 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+
*
51+
* @return
52+
* @since 1.10
53+
*/
54+
@AliasFor("maxExcecutionTime")
55+
long maxExecutionTimeMs() default -1;
56+
4457
/**
4558
* Only scan the specified number of documents.
46-
*
59+
*
4760
* @return
4861
*/
4962
long maxScanDocuments() default -1;
5063

5164
/**
5265
* Add a comment to the query.
53-
*
66+
*
5467
* @return
5568
*/
5669
String comment() default "";
5770

5871
/**
5972
* Using snapshot prevents the cursor from returning a document more than once.
60-
*
73+
*
6174
* @return
6275
*/
6376
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)