deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject deltaspike git commit: DELTASPIKE-836 Case insensitive query expressions
Date Mon, 23 Feb 2015 21:32:12 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 4039f6fb9 -> 1c210af91


DELTASPIKE-836 Case insensitive query expressions

- Add IgnoreCase option for Like and Equals comparisons
- Special parameter conversion for LikeIgnoreCase


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/1c210af9
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/1c210af9
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/1c210af9

Branch: refs/heads/master
Commit: 1c210af91668c807481fa5b3de3e5b6fef52821f
Parents: 4039f6f
Author: Thomas Hug <Thomas.Hug@ctp.com>
Authored: Mon Feb 23 16:42:45 2015 +0100
Committer: Thomas Hug <Thomas.Hug@ctp.com>
Committed: Mon Feb 23 16:59:39 2015 +0100

----------------------------------------------------------------------
 .../data/impl/builder/MethodQueryBuilder.java   |  1 +
 .../data/impl/builder/QueryBuilderContext.java  | 18 ++++++++
 .../data/impl/builder/QueryOperator.java        | 21 +++++++++
 .../impl/builder/part/PropertyQueryPart.java    |  5 +++
 .../data/impl/builder/part/QueryRoot.java       |  9 ++++
 .../data/impl/param/IndexedParameter.java       | 17 ++++++-
 .../data/impl/param/NamedParameter.java         | 10 ++++-
 .../deltaspike/data/impl/param/Parameter.java   | 20 +++++++--
 .../data/impl/param/ParameterUpdate.java        | 28 ++++++++++++
 .../deltaspike/data/impl/param/Parameters.java  | 18 +++++++-
 .../param/ToUpperStringParameterUpdate.java     | 47 ++++++++++++++++++++
 .../data/impl/builder/part/QueryRootTest.java   |  7 +--
 .../data/impl/handler/QueryHandlerTest.java     | 28 ++++++++++++
 .../data/test/service/SimpleRepository.java     |  4 ++
 .../data/test/util/TestDeployments.java         |  1 -
 15 files changed, 220 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/MethodQueryBuilder.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/MethodQueryBuilder.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/MethodQueryBuilder.java
index 11af97e..e7ba319 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/MethodQueryBuilder.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/MethodQueryBuilder.java
@@ -43,6 +43,7 @@ public class MethodQueryBuilder extends QueryBuilder
         QueryRoot root = context.getRepositoryMethod().getQueryRoot();
         String jpqlQuery = context.applyQueryStringPostProcessors(root.getJpqlQuery());
         context.setQueryString(jpqlQuery);
+        params.updateValues(root.getParameterUpdates());
         Query result = params.applyTo(context.getEntityManager().createQuery(jpqlQuery));
         return applyRestrictions(context, result);
     }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryBuilderContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryBuilderContext.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryBuilderContext.java
index 8730ec6..bd0768a 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryBuilderContext.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryBuilderContext.java
@@ -18,15 +18,23 @@
  */
 package org.apache.deltaspike.data.impl.builder;
 
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.deltaspike.data.impl.param.ParameterUpdate;
+
 public class QueryBuilderContext
 {
 
     private final StringBuilder builder;
+    private final List<ParameterUpdate> paramUpdates;
     private int counter = 1;
 
     public QueryBuilderContext()
     {
         this.builder = new StringBuilder();
+        this.paramUpdates = new LinkedList<ParameterUpdate>();
     }
 
     public int increment()
@@ -50,4 +58,14 @@ public class QueryBuilderContext
         return counter;
     }
 
+    public void addParameterUpdate(ParameterUpdate update)
+    {
+        paramUpdates.add(update);
+    }
+
+    public List<ParameterUpdate> getParameterUpdates()
+    {
+        return Collections.unmodifiableList(paramUpdates);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryOperator.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryOperator.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryOperator.java
index c2b79c7..2c84eb9 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryOperator.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/QueryOperator.java
@@ -29,8 +29,12 @@ public enum QueryOperator
     GreaterThan("GreaterThan", "{0} > {1}"),
     GreaterThanEquals("GreaterThanEquals", "{0} >= {1}"),
     Like("Like", "{0} like {1}"),
+    LikeIgnoreCase("LikeIgnoreCase", "upper({0}) like {1}", true),
     NotEqual("NotEqual", "{0} <> {1}"),
+    NotEqualIgnoreCase("NotEqualIgnoreCase", "upper({0}) <> upper({1})"),
     Equal("Equal", "{0} = {1}"),
+    EqualIgnoreCase("EqualIgnoreCase", "upper({0}) = upper({1})"),
+    IgnoreCase("IgnoreCase", "upper({0}) = upper({1})"),
     Between("Between", "{0} between {1} and {2}", 2),
     IsNotNull("IsNotNull", "{0} IS NOT NULL", 0),
     IsNull("IsNull", "{0} IS NULL", 0);
@@ -38,17 +42,29 @@ public enum QueryOperator
     private final String expression;
     private final String jpql;
     private final int paramNum;
+    private final boolean caseInsensitive;
 
     private QueryOperator(String expression, String jpql)
     {
         this(expression, jpql, 1);
     }
 
+    private QueryOperator(String expression, String jpql, boolean caseInsensitive)
+    {
+        this(expression, jpql, 1, caseInsensitive);
+    }
+
     private QueryOperator(String expression, String jpql, int paramNum)
     {
+        this(expression, jpql, paramNum, false);
+    }
+
+    private QueryOperator(String expression, String jpql, int paramNum, boolean caseInsensitive)
+    {
         this.expression = expression;
         this.jpql = jpql;
         this.paramNum = paramNum;
+        this.caseInsensitive = caseInsensitive;
     }
 
     public String getExpression()
@@ -66,4 +82,9 @@ public enum QueryOperator
         return paramNum;
     }
 
+    public boolean isCaseInsensitive()
+    {
+        return caseInsensitive;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/PropertyQueryPart.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/PropertyQueryPart.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/PropertyQueryPart.java
index e3cc832..e0fe3aa 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/PropertyQueryPart.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/PropertyQueryPart.java
@@ -26,6 +26,7 @@ import org.apache.deltaspike.data.impl.builder.QueryBuilder;
 import org.apache.deltaspike.data.impl.builder.QueryBuilderContext;
 import org.apache.deltaspike.data.impl.builder.QueryOperator;
 import org.apache.deltaspike.data.impl.meta.RepositoryComponent;
+import org.apache.deltaspike.data.impl.param.ToUpperStringParameterUpdate;
 
 class PropertyQueryPart extends BasePropertyQueryPart
 {
@@ -62,6 +63,10 @@ class PropertyQueryPart extends BasePropertyQueryPart
             args[i] = "?" + ctx.increment();
         }
         ctx.append(MessageFormat.format(comparator.getJpql(), (Object[]) args));
+        if (comparator.isCaseInsensitive() && args.length >= 1)
+        {
+            ctx.addParameterUpdate(new ToUpperStringParameterUpdate(args[1].substring(1)));
+        }
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryRoot.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryRoot.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryRoot.java
index 9484634..1f734b2 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryRoot.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/builder/part/QueryRoot.java
@@ -21,6 +21,7 @@ package org.apache.deltaspike.data.impl.builder.part;
 import static org.apache.deltaspike.data.impl.util.QueryUtils.splitByKeyword;
 
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -30,6 +31,7 @@ import org.apache.deltaspike.data.impl.builder.QueryBuilder;
 import org.apache.deltaspike.data.impl.builder.QueryBuilderContext;
 import org.apache.deltaspike.data.impl.meta.MethodPrefix;
 import org.apache.deltaspike.data.impl.meta.RepositoryComponent;
+import org.apache.deltaspike.data.impl.param.ParameterUpdate;
 
 /**
  * Root of the query tree. Also the only exposed class in the package.
@@ -45,6 +47,7 @@ public class QueryRoot extends QueryPart
     private final MethodPrefix methodPrefix;
 
     private String jpqlQuery;
+    private List<ParameterUpdate> paramUpdates;
 
     protected QueryRoot(String entityName, MethodPrefix methodPrefix)
     {
@@ -65,6 +68,11 @@ public class QueryRoot extends QueryPart
         return jpqlQuery;
     }
 
+    public List<ParameterUpdate> getParameterUpdates()
+    {
+        return paramUpdates;
+    }
+
     @Override
     protected QueryPart build(String queryPart, String method, RepositoryComponent repo)
     {
@@ -109,6 +117,7 @@ public class QueryRoot extends QueryPart
         QueryBuilderContext ctx = new QueryBuilderContext();
         buildQuery(ctx);
         jpqlQuery = ctx.resultString();
+        paramUpdates = ctx.getParameterUpdates();
         log.log(Level.FINER, "createJpql: Query is {0}", jpqlQuery);
         return jpqlQuery;
     }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/IndexedParameter.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/IndexedParameter.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/IndexedParameter.java
index 0b81cad..863ba75 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/IndexedParameter.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/IndexedParameter.java
@@ -28,9 +28,9 @@ public class IndexedParameter extends Parameter
 
     private final int index;
 
-    public IndexedParameter(int index, Object value, int argIndex)
+    public IndexedParameter(int index, Object value)
     {
-        super(value, argIndex);
+        super(value);
         this.index = index;
     }
 
@@ -40,4 +40,17 @@ public class IndexedParameter extends Parameter
         query.setParameter(index, queryValue());
     }
 
+    @Override
+    public boolean is(String ident)
+    {
+        try
+        {
+            return Integer.valueOf(ident).intValue() == index;
+        }
+        catch (NumberFormatException e)
+        {
+            return false;
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/NamedParameter.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/NamedParameter.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/NamedParameter.java
index 60f8504..0ee3ca8 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/NamedParameter.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/NamedParameter.java
@@ -28,9 +28,9 @@ public class NamedParameter extends Parameter
 
     private final String name;
 
-    public NamedParameter(String name, Object value, int argIndex)
+    public NamedParameter(String name, Object value)
     {
-        super(value, argIndex);
+        super(value);
         this.name = name;
     }
 
@@ -40,4 +40,10 @@ public class NamedParameter extends Parameter
         query.setParameter(name, queryValue());
     }
 
+    @Override
+    public boolean is(String ident)
+    {
+        return ident != null && ident.equals(name);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/Parameter.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/Parameter.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/Parameter.java
index b85b26c..3d207d9 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/Parameter.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/Parameter.java
@@ -32,19 +32,19 @@ public abstract class Parameter
 {
     private static final Logger LOG = Logger.getLogger(Parameter.class.getName());
 
-    protected final Object value;
-    protected final int argIndex;
+    protected Object value;
 
     protected Object mappedValue = null;
 
-    public Parameter(Object value, int argIndex)
+    public Parameter(Object value)
     {
         this.value = value;
-        this.argIndex = argIndex;
     }
 
     public abstract void apply(Query query);
 
+    public abstract boolean is(String ident);
+
     public void applyMapper(QueryInOutMapper<?> mapper)
     {
         if (mapper.mapsParameter(value))
@@ -54,6 +54,18 @@ public abstract class Parameter
         }
     }
 
+    public void updateValue(Object newValue)
+    {
+        if (mappedValue != null)
+        {
+            mappedValue = newValue;
+        }
+        else
+        {
+            value = newValue;
+        }
+    }
+
     protected Object queryValue()
     {
         return mappedValue != null ? mappedValue : value;

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/ParameterUpdate.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/ParameterUpdate.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/ParameterUpdate.java
new file mode 100644
index 0000000..7c360a7
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/ParameterUpdate.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.deltaspike.data.impl.param;
+
+public interface ParameterUpdate
+{
+
+    String forParamWithId();
+
+    Object newParamValue(Object current);
+
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/Parameters.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/Parameters.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/Parameters.java
index 9e6c20a..76b8dae 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/Parameters.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/Parameters.java
@@ -75,11 +75,11 @@ public final class Parameters
                 QueryParam qpAnnotation = extractFrom(annotations[i], QueryParam.class);
                 if (qpAnnotation != null)
                 {
-                    result.add(new NamedParameter(qpAnnotation.value(), parameters[i], i));
+                    result.add(new NamedParameter(qpAnnotation.value(), parameters[i]));
                 }
                 else
                 {
-                    result.add(new IndexedParameter(paramIndex++, parameters[i], i));
+                    result.add(new IndexedParameter(paramIndex++, parameters[i]));
                 }
             }
             else
@@ -99,6 +99,20 @@ public final class Parameters
         }
     }
 
+    public void updateValues(List<ParameterUpdate> updates)
+    {
+        for (ParameterUpdate update : updates)
+        {
+            for (Parameter param : parameterList)
+            {
+                if (param.is(update.forParamWithId()))
+                {
+                    param.updateValue(update.newParamValue(param.queryValue()));
+                }
+            }
+        }
+    }
+
     public Query applyTo(Query query)
     {
         for (Parameter param : parameterList)

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/ToUpperStringParameterUpdate.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/ToUpperStringParameterUpdate.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/ToUpperStringParameterUpdate.java
new file mode 100644
index 0000000..f121beb
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/param/ToUpperStringParameterUpdate.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.deltaspike.data.impl.param;
+
+public class ToUpperStringParameterUpdate implements ParameterUpdate
+{
+
+    private final String id;
+
+    public ToUpperStringParameterUpdate(String id)
+    {
+        this.id = id;
+    }
+
+    @Override
+    public String forParamWithId()
+    {
+        return id;
+    }
+
+    @Override
+    public Object newParamValue(Object current)
+    {
+        if (current instanceof String)
+        {
+            return ((String) current).toUpperCase();
+        }
+        return current;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/builder/part/QueryRootTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/builder/part/QueryRootTest.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/builder/part/QueryRootTest.java
index 3184669..809954f 100644
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/builder/part/QueryRootTest.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/builder/part/QueryRootTest.java
@@ -55,14 +55,15 @@ public class QueryRootTest
     {
         // given
         final String name = "findByNameAndTemporalBetweenOrEnabledIsNull" +
-                "AndCamelCaseAndEmbedded_embeddNotEqualOrderByEmbedded_embeddDesc";
+                "AndCamelCaseLikeIgnoreCaseAndEmbedded_embeddNotEqualIgnoreCase" +
+                "OrderByEmbedded_embeddDesc";
         final String expected =
                 "select e from Simple e " +
                         "where e.name = ?1 " +
                         "and e.temporal between ?2 and ?3 " +
                         "or e.enabled IS NULL " +
-                        "and e.camelCase = ?4 " +
-                        "and e.embedded.embedd <> ?5 " +
+                        "and upper(e.camelCase) like ?4 " +
+                        "and upper(e.embedded.embedd) <> upper(?5) " +
                         "order by e.embedded.embedd desc";
 
         // when

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/QueryHandlerTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/QueryHandlerTest.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/QueryHandlerTest.java
index 6b31157..b12e344 100644
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/QueryHandlerTest.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/QueryHandlerTest.java
@@ -370,6 +370,34 @@ public class QueryHandlerTest extends TransactionalTestCase
         assertNull(result2);
     }
 
+    @Test
+    public void should_create_case_insensitive_query_for_like_comparator()
+    {
+        // given
+        final String name = "Should_Create_Case_Insensitive_Query_For_Like";
+        builder.createSimple(name);
+
+        // when
+        Simple result = repo.findByNameLikeIgnoreCase("should_create_CASE_Insensitive_QUERY_for_l%");
+
+        // then
+        assertEquals(name, result.getName());
+    }
+
+    @Test
+    public void should_create_case_insensitive_query_for_equals_comparator()
+    {
+        // given
+        final String name = "Should_Create_Case_Insensitive_Query_for_Equals";
+        builder.createSimple(name);
+
+        // when
+        Simple result = repo.findByNameIgnoreCase("should_create_case_insensitive_query_for_equals");
+
+        // then
+        assertEquals(name, result.getName());
+    }
+
     @Before
     public void setup()
     {

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java
index 4f1092e..2c3b4e3 100755
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java
@@ -76,6 +76,10 @@ public abstract class SimpleRepository extends AbstractEntityRepository<Simple,
 
     public abstract Simple findByNameAndEnabled(String name, Boolean enabled);
 
+    public abstract Simple findByNameLikeIgnoreCase(String name);
+
+    public abstract Simple findByNameIgnoreCase(String name);
+
     public abstract Simple findOptionalByName(String name);
 
     public abstract Simple findAnyByName(String name);

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/1c210af9/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/util/TestDeployments.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/util/TestDeployments.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/util/TestDeployments.java
index 645bc01..3e34d34 100755
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/util/TestDeployments.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/util/TestDeployments.java
@@ -62,7 +62,6 @@ import org.apache.deltaspike.data.test.TransactionalTestCase;
 import org.apache.deltaspike.data.test.domain.AuditedEntity;
 import org.apache.deltaspike.jpa.impl.transaction.EnvironmentAwareTransactionStrategy;
 import org.apache.deltaspike.test.category.WebProfileCategory;
-import org.apache.deltaspike.test.utils.CdiContainerUnderTest;
 import org.jboss.arquillian.container.test.spi.TestDeployment;
 import org.jboss.shrinkwrap.api.Archive;
 import org.jboss.shrinkwrap.api.ArchivePath;


Mime
View raw message