ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpav...@apache.org
Subject ignite git commit: IGNITE-8044 IgniteQueryGenerator.getOptions() method should properly handle empty list of parameters - Fixes #3705.
Date Mon, 02 Apr 2018 15:23:05 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 122816e94 -> 6875ac3e0


IGNITE-8044 IgniteQueryGenerator.getOptions() method should properly handle empty list of
parameters - Fixes #3705.

Signed-off-by: dpavlov <dpavlov@gridgain.com>


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6875ac3e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6875ac3e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6875ac3e

Branch: refs/heads/master
Commit: 6875ac3e069358af43586ad7068cfb7c50d8c08f
Parents: 122816e
Author: Slava Koptilin <slava.koptilin@gmail.com>
Authored: Mon Apr 2 18:22:07 2018 +0300
Committer: dpavlov <dpavlov@gridgain.com>
Committed: Mon Apr 2 18:22:07 2018 +0300

----------------------------------------------------------------------
 .../repository/query/IgniteQueryGenerator.java   | 19 ++++++++++---------
 .../IgniteSpringDataQueriesSelfTest.java         |  9 +++++++++
 .../ignite/springdata/misc/PersonRepository.java |  4 ++++
 3 files changed, 23 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6875ac3e/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/query/IgniteQueryGenerator.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/query/IgniteQueryGenerator.java
b/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/query/IgniteQueryGenerator.java
index 2381c8d..3fe0780 100644
--- a/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/query/IgniteQueryGenerator.java
+++ b/modules/spring-data/src/main/java/org/apache/ignite/springdata/repository/query/IgniteQueryGenerator.java
@@ -139,17 +139,18 @@ public class IgniteQueryGenerator {
      * @return type of options
      */
     public static IgniteQuery.Option getOptions(Method mtd) {
-        IgniteQuery.Option option;
+        IgniteQuery.Option option = IgniteQuery.Option.NONE;
 
         Class<?>[] types = mtd.getParameterTypes();
-        Class<?> type = types[types.length - 1];
-
-        if (Sort.class.isAssignableFrom(type))
-            option = IgniteQuery.Option.SORTING;
-        else if (Pageable.class.isAssignableFrom(type))
-            option = IgniteQuery.Option.PAGINATION;
-        else
-            option = IgniteQuery.Option.NONE;
+
+        if (types.length > 0) {
+            Class<?> type = types[types.length - 1];
+
+            if (Sort.class.isAssignableFrom(type))
+                option = IgniteQuery.Option.SORTING;
+            else if (Pageable.class.isAssignableFrom(type))
+                option = IgniteQuery.Option.PAGINATION;
+        }
 
         for (int i = 0; i < types.length - 1; i++) {
             Class<?> tp = types[i];

http://git-wip-us.apache.org/repos/asf/ignite/blob/6875ac3e/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java
b/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java
index 40b7df2..74e8ea4 100644
--- a/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java
+++ b/modules/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataQueriesSelfTest.java
@@ -287,5 +287,14 @@ public class IgniteSpringDataQueriesSelfTest extends GridCommonAbstractTest
{
             assertTrue(list.get(0) instanceof Integer);
         }
     }
+
+    /**
+     * Tests the repository method with a custom query which takes no parameters.
+     */
+    public void testCountAllPersons() {
+        int cnt = repo.countAllPersons();
+
+        assertEquals(CACHE_SIZE, cnt);
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6875ac3e/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/PersonRepository.java
----------------------------------------------------------------------
diff --git a/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/PersonRepository.java
b/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/PersonRepository.java
index 88f47d9..aa89d43 100644
--- a/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/PersonRepository.java
+++ b/modules/spring-data/src/test/java/org/apache/ignite/springdata/misc/PersonRepository.java
@@ -88,5 +88,9 @@ public interface PersonRepository extends IgniteRepository<Person, Integer>
{
     /** */
     @Query("SELECT count(1) FROM (SELECT DISTINCT secondName FROM Person WHERE firstName
REGEXP ?)")
     public int countQuery(String val);
+
+    /** */
+    @Query("SELECT count(*) FROM Person")
+    public int countAllPersons();
 }
 


Mime
View raw message