diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/CompoundIndex.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/CompoundIndex.java index be7c1f8c7..c28549dec 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/CompoundIndex.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/CompoundIndex.java @@ -25,23 +25,20 @@ import java.lang.annotation.Target; /** * Mark a class to use compound indexes. *
- * Some situations may require to have more than one {@link CompoundIndex}. For those scenarios {@link CompoundIndexes} - * functions as container annotation for multiple {@link CompoundIndex} annotations via the - * {@link CompoundIndexes#value()} or by repeating the {@link CompoundIndex} on the class itself. - * - *
- *
- *
+ *
+ * NOTE: This annotation is repeatable according to Java 8 conventions using {@link CompoundIndexes#value()} as
+ * container.
+ *
+ *
* @Document
* @CompoundIndex(def = "{'firstname': 1, 'lastname': 1}")
* @CompoundIndex(def = "{'address.city': 1, 'address.street': 1}")
* class Person {
- * String firstname;
- * String lastname;
+ * String firstname;
+ * String lastname;
*
- * Address address;
+ * Address address;
* }
- *
*
*
* @author Jon Brisbin
@@ -63,9 +60,7 @@ public @interface CompoundIndex {
*
- *
- *
+ *
* @Document
* @CompoundIndex(def = "{'h1': 1, 'h2': 1}")
* class JsonStringIndexDefinition {
@@ -77,7 +72,6 @@ public @interface CompoundIndex {
* class ExpressionIndexDefinition {
* String h1, h2;
* }
- *
*
*
* @return
@@ -127,35 +121,31 @@ public @interface CompoundIndex {
*
- *
+ *
* @Document
* class Root {
- * Hybrid hybrid;
- * Nested nested;
+ * Hybrid hybrid;
+ * Nested nested;
* }
*
* @Document
* @CompoundIndex(name = "compound_index", def = "{'h1': 1, 'h2': 1}")
* class Hybrid {
- * String h1, h2;
+ * String h1, h2;
* }
*
* @CompoundIndex(name = "compound_index", def = "{'n1': 1, 'n2': 1}")
* class Nested {
- * String n1, n2;
+ * String n1, n2;
* }
- *
*
*
* resolves in the following index structures
*
- *
- *
+ *
* db.root.createIndex( { hybrid.h1: 1, hybrid.h2: 1 } , { name: "hybrid.compound_index" } )
* db.root.createIndex( { nested.n1: 1, nested.n2: 1 } , { name: "nested.compound_index" } )
* db.hybrid.createIndex( { h1: 1, h2: 1 } , { name: "compound_index" } )
- *
*
*
* @return
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/CompoundIndexes.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/CompoundIndexes.java
index 6494a7a73..1d57079cb 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/CompoundIndexes.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/CompoundIndexes.java
@@ -23,6 +23,10 @@ import java.lang.annotation.Target;
/**
* Container annotation that allows to collect multiple {@link CompoundIndex} annotations.
+ *
+ * Can be used natively, declaring several nested {@link CompoundIndex} annotations. Can also be used in conjunction
+ * with Java 8's support for repeatable annotations, where {@link CompoundIndex} can simply be declared several
+ * times on the same {@linkplain ElementType#TYPE type}, implicitly generating this container annotation.
*
* @author Jon Brisbin
* @author Christoph Strobl
diff --git a/src/main/asciidoc/reference/mapping.adoc b/src/main/asciidoc/reference/mapping.adoc
index db2fee0ef..bbb790b50 100644
--- a/src/main/asciidoc/reference/mapping.adoc
+++ b/src/main/asciidoc/reference/mapping.adoc
@@ -428,9 +428,7 @@ Here is an example of a more complex mapping.
[source,java]
----
@Document
-@CompoundIndexes({
- @CompoundIndex(name = "age_idx", def = "{'lastName': 1, 'age': -1}")
-})
+@CompoundIndex(name = "age_idx", def = "{'lastName': 1, 'age': -1}")
public class Person