DATACMNS-875 - Add support for exists projection in repository query derivation.

We now support exists projections in derived queries by parsing the exists keyword and expose it via PartTree.isExistsProjection().

Original pull request: #171.
This commit is contained in:
Mark Paluch
2016-06-28 14:25:12 +02:00
committed by Oliver Gierke
parent 2b14d1ea54
commit 8bc022ebd7
2 changed files with 50 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2015 the original author or authors.
* Copyright 2008-2016 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
@@ -44,10 +44,11 @@ import org.springframework.data.repository.query.parser.PartTree.OrPart;
* @author Thomas Darimont
* @author Martin Baumgartner
* @author Christoph Strobl
* @author Mark Paluch
*/
public class PartTreeUnitTests {
private String[] PREFIXES = { "find", "read", "get", "query", "stream", "count", "delete", "remove" };
private String[] PREFIXES = { "find", "read", "get", "query", "stream", "count", "delete", "remove", "exists" };
@Test(expected = IllegalArgumentException.class)
public void rejectsNullSource() throws Exception {
@@ -436,6 +437,16 @@ public class PartTreeUnitTests {
assertThat(tree.isCountProjection(), is(true));
}
/**
* @see DATACMNS-875
*/
@Test
public void identifiesSimpleExistsByCorrectly() {
PartTree tree = new PartTree("existsByLastname", User.class);
assertThat(tree.isExistsProjection(), is(true));
}
/**
* @see DATACMNS-399
*/
@@ -652,6 +663,16 @@ public class PartTreeUnitTests {
assertLimiting("countTop10DistinctUsersByLastname", User.class, false, null, true);
}
/**
* @see DATACMNS-875
*/
@Test
public void shouldNotSupportLimitingExistQueries() {
assertLimiting("existsFirst10DistinctUsersByLastname", User.class, false, null, true);
assertLimiting("existsTop10DistinctUsersByLastname", User.class, false, null, true);
}
/**
* @see DATACMNS-581
*/