findByFirstname(String firstname);
+}
diff --git a/mongodb/example/src/main/java/example/springdata/mongodb/advanced/ApplicationConfiguration.java b/mongodb/example/src/main/java/example/springdata/mongodb/advanced/ApplicationConfiguration.java
new file mode 100644
index 00000000..4bc0a9de
--- /dev/null
+++ b/mongodb/example/src/main/java/example/springdata/mongodb/advanced/ApplicationConfiguration.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package example.springdata.mongodb.advanced;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.mongodb.core.MongoOperations;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.MongoClient;
+
+/**
+ * Test configuration to connect to a MongoDB named "test" and using a {@link MongoClient} with profiling enabled.
+ *
+ * @author Christoph Strobl
+ */
+@Configuration
+@EnableAutoConfiguration
+class ApplicationConfiguration {
+
+ static final String SYSTEM_PROFILE_DB = "system.profile";
+
+ @Autowired MongoOperations operations;
+
+ /**
+ * Initialize db instance with defaults.
+ */
+ @PostConstruct
+ public void initializeWithDefaults() {
+
+ // Enable profiling
+ setProfilingLevel(2);
+ }
+
+ /**
+ * Clean up resources on shutdown
+ */
+ @PreDestroy
+ public void cleanUpWhenShuttingDown() {
+
+ // Disable profiling
+ setProfilingLevel(0);
+
+ if (operations.collectionExists(SYSTEM_PROFILE_DB)) {
+ operations.dropCollection(SYSTEM_PROFILE_DB);
+ }
+ }
+
+ private void setProfilingLevel(int level) {
+ operations.executeCommand(new BasicDBObject("profile", level));
+ }
+}
diff --git a/mongodb/geo-spatial/src/main/java/example/springdata/mongodb/customer/Address.java b/mongodb/example/src/main/java/example/springdata/mongodb/customer/Address.java
similarity index 100%
rename from mongodb/geo-spatial/src/main/java/example/springdata/mongodb/customer/Address.java
rename to mongodb/example/src/main/java/example/springdata/mongodb/customer/Address.java
diff --git a/mongodb/geo-spatial/src/main/java/example/springdata/mongodb/customer/ApplicationConfiguration.java b/mongodb/example/src/main/java/example/springdata/mongodb/customer/ApplicationConfiguration.java
similarity index 96%
rename from mongodb/geo-spatial/src/main/java/example/springdata/mongodb/customer/ApplicationConfiguration.java
rename to mongodb/example/src/main/java/example/springdata/mongodb/customer/ApplicationConfiguration.java
index 97fa329a..e5af31e3 100644
--- a/mongodb/geo-spatial/src/main/java/example/springdata/mongodb/customer/ApplicationConfiguration.java
+++ b/mongodb/example/src/main/java/example/springdata/mongodb/customer/ApplicationConfiguration.java
@@ -28,4 +28,4 @@ import com.mongodb.MongoClient;
*/
@Configuration
@EnableAutoConfiguration
-public class ApplicationConfiguration {}
+class ApplicationConfiguration {}
diff --git a/mongodb/geo-spatial/src/main/java/example/springdata/mongodb/customer/Customer.java b/mongodb/example/src/main/java/example/springdata/mongodb/customer/Customer.java
similarity index 100%
rename from mongodb/geo-spatial/src/main/java/example/springdata/mongodb/customer/Customer.java
rename to mongodb/example/src/main/java/example/springdata/mongodb/customer/Customer.java
diff --git a/mongodb/geo-spatial/src/main/java/example/springdata/mongodb/customer/CustomerRepository.java b/mongodb/example/src/main/java/example/springdata/mongodb/customer/CustomerRepository.java
similarity index 100%
rename from mongodb/geo-spatial/src/main/java/example/springdata/mongodb/customer/CustomerRepository.java
rename to mongodb/example/src/main/java/example/springdata/mongodb/customer/CustomerRepository.java
diff --git a/mongodb/example/src/test/java/example/springdata/mongodb/advanced/AdvancedIntegrationTests.java b/mongodb/example/src/test/java/example/springdata/mongodb/advanced/AdvancedIntegrationTests.java
new file mode 100644
index 00000000..1ceb3f44
--- /dev/null
+++ b/mongodb/example/src/test/java/example/springdata/mongodb/advanced/AdvancedIntegrationTests.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package example.springdata.mongodb.advanced;
+
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.MongoOperations;
+import org.springframework.data.mongodb.core.query.Meta;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+
+import example.springdata.mongodb.customer.Customer;
+
+/**
+ * @author Christoph Strobl
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = ApplicationConfiguration.class)
+public class AdvancedIntegrationTests {
+
+ @Autowired AdvancedRepository repository;
+ @Autowired MongoOperations operations;
+
+ Customer dave, oliver, carter;
+
+ @Before
+ public void setUp() {
+
+ repository.deleteAll();
+
+ dave = repository.save(new Customer("Dave", "Matthews"));
+ oliver = repository.save(new Customer("Oliver August", "Matthews"));
+ carter = repository.save(new Customer("Carter", "Beauford"));
+ }
+
+ /**
+ * This test demonstrates usage of {@code $comment} {@link Meta} usage. One can also enable profiling using
+ * {@code --profile=2} when starting {@literal mongod}.
+ *
+ * NOTE: Requires MongoDB v. 2.6.4+
+ */
+ @Test
+ public void findByFirstnameUsingMetaAttributes() {
+
+ // execute derived finder method just to get the comment in the profile log
+ repository.findByFirstname(dave.getFirstname());
+
+ // execute another finder without meta attributes that should not be picked up
+ repository.findByLastname(dave.getLastname(), new Sort("firstname"));
+
+ DBCursor cursor = operations.getCollection(ApplicationConfiguration.SYSTEM_PROFILE_DB).find(
+ new BasicDBObject("query.$comment", AdvancedRepository.META_COMMENT));
+
+ while (cursor.hasNext()) {
+
+ DBObject dbo = cursor.next();
+ DBObject query = (DBObject) dbo.get("query");
+
+ assertThat(query.containsField("$comment"), is(true));
+ }
+ }
+}
diff --git a/mongodb/example/src/test/java/example/springdata/mongodb/advanced/package-info.java b/mongodb/example/src/test/java/example/springdata/mongodb/advanced/package-info.java
new file mode 100644
index 00000000..81b41fed
--- /dev/null
+++ b/mongodb/example/src/test/java/example/springdata/mongodb/advanced/package-info.java
@@ -0,0 +1,5 @@
+/**
+ * Package showing usage of Spring Data abstractions for special (advanced) MongoDB operations.
+ */
+package example.springdata.mongodb.advanced;
+
diff --git a/mongodb/geo-spatial/src/test/java/example/springdata/mongodb/customer/CustomerRepositoryIntegrationTest.java b/mongodb/example/src/test/java/example/springdata/mongodb/customer/CustomerRepositoryIntegrationTest.java
similarity index 100%
rename from mongodb/geo-spatial/src/test/java/example/springdata/mongodb/customer/CustomerRepositoryIntegrationTest.java
rename to mongodb/example/src/test/java/example/springdata/mongodb/customer/CustomerRepositoryIntegrationTest.java
diff --git a/mongodb/example/src/test/java/example/springdata/mongodb/customer/package-info.java b/mongodb/example/src/test/java/example/springdata/mongodb/customer/package-info.java
new file mode 100644
index 00000000..e5f88299
--- /dev/null
+++ b/mongodb/example/src/test/java/example/springdata/mongodb/customer/package-info.java
@@ -0,0 +1,5 @@
+/**
+ * Package showing basic usage of Spring Data MongoDB Repositories.
+ */
+package example.springdata.mongodb.customer;
+
diff --git a/mongodb/pom.xml b/mongodb/pom.xml
index 7a0a644c..d30642ad 100644
--- a/mongodb/pom.xml
+++ b/mongodb/pom.xml
@@ -17,7 +17,7 @@
2011-2014
- geo-spatial
+ example
aggregation
text-search