diff --git a/pom.xml b/pom.xml
index 3477cb090d..4f2bc199ac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.7.0.BUILD-SNAPSHOT
+ 1.7.0.DATAMONGO-1146-SNAPSHOT
pom
Spring Data MongoDB
diff --git a/spring-data-mongodb-cross-store/pom.xml b/spring-data-mongodb-cross-store/pom.xml
index 40e8a0f253..530131dc70 100644
--- a/spring-data-mongodb-cross-store/pom.xml
+++ b/spring-data-mongodb-cross-store/pom.xml
@@ -6,7 +6,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.7.0.BUILD-SNAPSHOT
+ 1.7.0.DATAMONGO-1146-SNAPSHOT
../pom.xml
@@ -48,7 +48,7 @@
org.springframework.data
spring-data-mongodb
- 1.7.0.BUILD-SNAPSHOT
+ 1.7.0.DATAMONGO-1146-SNAPSHOT
diff --git a/spring-data-mongodb-distribution/pom.xml b/spring-data-mongodb-distribution/pom.xml
index 13110137b6..a2c7dad63c 100644
--- a/spring-data-mongodb-distribution/pom.xml
+++ b/spring-data-mongodb-distribution/pom.xml
@@ -13,7 +13,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.7.0.BUILD-SNAPSHOT
+ 1.7.0.DATAMONGO-1146-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb-log4j/pom.xml b/spring-data-mongodb-log4j/pom.xml
index 6ff09e4577..18e789b7b1 100644
--- a/spring-data-mongodb-log4j/pom.xml
+++ b/spring-data-mongodb-log4j/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.7.0.BUILD-SNAPSHOT
+ 1.7.0.DATAMONGO-1146-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb/pom.xml b/spring-data-mongodb/pom.xml
index 7c2d818c42..a5771b3565 100644
--- a/spring-data-mongodb/pom.xml
+++ b/spring-data-mongodb/pom.xml
@@ -11,7 +11,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.7.0.BUILD-SNAPSHOT
+ 1.7.0.DATAMONGO-1146-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/QueryDslMongoRepository.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/QueryDslMongoRepository.java
index 9aaddd2db4..92dce338f4 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/QueryDslMongoRepository.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/QueryDslMongoRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2014 the original author or authors.
+ * Copyright 2011-2015 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.
@@ -161,6 +161,13 @@ public long count(Predicate predicate) {
return createQueryFor(predicate).count();
}
+ /* (non-Javadoc)
+ * @see org.springframework.data.querydsl.QueryDslPredicateExecutor#exists(com.mysema.query.types.Predicate)
+ */
+ public boolean exists(Predicate predicate) {
+ return createQueryFor(predicate).exists();
+ }
+
/**
* Creates a {@link MongodbQuery} for the given {@link Predicate}.
*
diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/QueryDslMongoRepositoryIntegrationTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/QueryDslMongoRepositoryIntegrationTests.java
new file mode 100644
index 0000000000..3809fbb415
--- /dev/null
+++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/QueryDslMongoRepositoryIntegrationTests.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2015 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 org.springframework.data.mongodb.repository.support;
+
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoOperations;
+import org.springframework.data.mongodb.repository.Person;
+import org.springframework.data.mongodb.repository.QPerson;
+import org.springframework.data.mongodb.repository.query.MongoEntityInformation;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.mysema.query.types.Predicate;
+
+/**
+ * Integration test for {@link QueryDslMongoRepository}.
+ *
+ * @author Thomas Darimont
+ */
+@ContextConfiguration(
+ locations = "/org/springframework/data/mongodb/repository/PersonRepositoryIntegrationTests-context.xml")
+@RunWith(SpringJUnit4ClassRunner.class)
+public class QueryDslMongoRepositoryIntegrationTests {
+
+ @Autowired MongoOperations operations;
+ QueryDslMongoRepository repository;
+
+ Person dave, oliver, carter;
+ QPerson person;
+
+ @Before
+ public void setup() {
+
+ MongoRepositoryFactory factory = new MongoRepositoryFactory(operations);
+ MongoEntityInformation entityInformation = factory.getEntityInformation(Person.class);
+ repository = new QueryDslMongoRepository(entityInformation, operations);
+
+ operations.dropCollection(Person.class);
+
+ dave = new Person("Dave", "Matthews", 42);
+ oliver = new Person("Oliver August", "Matthews", 4);
+ carter = new Person("Carter", "Beauford", 49);
+
+ person = new QPerson("person");
+
+ repository.save(Arrays.asList(oliver, dave, carter));
+ }
+
+ /**
+ * @see DATAMONGO-1146
+ */
+ @Test
+ public void shouldSupportExistsWithPredicate() throws Exception {
+
+ assertThat(repository.exists(person.firstname.eq("Dave")), is(true));
+ assertThat(repository.exists(person.firstname.eq("Unknown")), is(false));
+ assertThat(repository.exists((Predicate) null), is(true));
+ }
+}