# "Unable to ignore case of java.lang.String types", ignoreCase combined with Contains not working

**URL:** https://community.neo4j.com/t/unable-to-ignore-case-of-java-lang-string-types-ignorecase-combined-with-contains-not-working/5041
**Category:** Spring Data Neo4j & Neo4j-OGM
**Created:** [February 13, 2019, 2:06pm UTC](https://community.neo4j.com/t/unable-to-ignore-case-of-java-lang-string-types-ignorecase-combined-with-contains-not-working/5041 "2019-02-13T14:06:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![moritz.loeser](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/moritz.loeser/32/2936_2.png) [@moritz.loeser](https://community.neo4j.com/u/moritz.loeser)
#### Post date: [February 13, 2019, 2:06pm UTC](https://community.neo4j.com/t/unable-to-ignore-case-of-java-lang-string-types-ignorecase-combined-with-contains-not-working/5041/1 "2019-02-13T14:06:01Z")

</div>

So far Spring-Data-Neo4J works great but now i am hitting a problem:

In one of my "Neo4jRepository" for `ProductResponsibleUnitRelation` i declare a method:

```auto
List<ProductResponsibleUnitRelation> findByProductHierarchyIdContainingIgnoreCase(String partialProductHierarchyId);

```

Using this method yields this exception:

```auto
Caused by: java.lang.IllegalStateException: Unable to ignore case of java.lang.String types, the property 'productHierarchy' must reference a String
	at org.springframework.util.Assert.state(Assert.java:73)
	at org.springframework.data.neo4j.repository.query.filter.PropertyComparisonBuilder.applyCaseInsensitivityIfShouldIgnoreCase(PropertyComparisonBuilder.java:101)
	at org.springframework.data.neo4j.repository.query.filter.PropertyComparisonBuilder.build(PropertyComparisonBuilder.java:49)

```

Inspecting code of org.springframework.data.neo4j.repository.query.filter.PropertyComparisonBuilder reveals the problem. The method `canIgnoreCase` is called it looks like this:

```auto
	private boolean canIgnoreCase(Part part) {
		return part.getType() == SIMPLE_PROPERTY && String.class.equals(part.getProperty().getLeafType());
	}

```

It seems that the use of IgnoreCase (`part.getType()`) is only allowed for `SIMPLE_PROPERTY` but no for all others like `CONTAINING`.

The question is: How could i get a working findByContainingIgnoreCase method, preferable without using cypher (i am using spring data to abstract from these details).

My OGM calsses are these:

```auto
@RelationshipEntity(type = "responsible_for_product")
@Data
public class ProductResponsibleUnitRelation {

    @Id
    @GeneratedValue
    private Long id;

    @StartNode
    private LegalEntityNode legalEntity;

    @EndNode
    private ProductHierarchyNode productHierarchy;

    private LocalDate validFrom;

    private LocalDate validTo;

}

```

```auto
@NodeEntity
@Data
public class ProductHierarchyNode {
    @Id
    private String id;

}

```

I want to find all relations by case insensitive parts ("containing") of the id.

---

<div class="post-metadata">

### Author: ![gerrit.meier](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/gerrit.meier/32/27374_2.png) [@gerrit.meier](https://community.neo4j.com/u/gerrit.meier)
#### Post date: [February 13, 2019, 2:17pm UTC](https://community.neo4j.com/t/unable-to-ignore-case-of-java-lang-string-types-ignorecase-combined-with-contains-not-working/5041/2 "2019-02-13T14:17:10Z")

</div>

This will be part of the Spring Data Neo4j Moore release. The ticket is already solved [Allow concatenation of ignoreCase modifier keyword [DATAGRAPH-1190] · Issue #1752 · spring-projects/spring-data-neo4j · GitHub](https://jira.spring.io/browse/DATAGRAPH-1190)

---

<div class="post-metadata">

### Author: ![moritz.loeser](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/moritz.loeser/32/2936_2.png) [@moritz.loeser](https://community.neo4j.com/u/moritz.loeser)
#### Post date: [February 13, 2019, 2:59pm UTC](https://community.neo4j.com/t/unable-to-ignore-case-of-java-lang-string-types-ignorecase-combined-with-contains-not-working/5041/3 "2019-02-13T14:59:40Z")

</div>

Thanks for quick reply,

is there a plan when 5.2 M2 (Moore) is available?  
Is there any workaround available?

---

<div class="post-metadata">

### Author: ![gerrit.meier](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/gerrit.meier/32/27374_2.png) [@gerrit.meier](https://community.neo4j.com/u/gerrit.meier)
#### Post date: [February 13, 2019, 3:05pm UTC](https://community.neo4j.com/t/unable-to-ignore-case-of-java-lang-string-types-ignorecase-combined-with-contains-not-working/5041/4 "2019-02-13T15:05:07Z")

</div>

The Spring Data releases are managed by Pivotal and Moore M2 is currently scheduled for March 7th ([https://spring-calendar.cfapps.io/](https://spring-calendar.cfapps.io/)).

You could go with a regex e.g. `findByNameRegex(String regex)`. Have a look at the test/example [spring-data-neo4j/RestaurantTests.java at e4450fdd9866ca7451f1cb8bee375cec532dcdf2 · spring-projects/spring-data-neo4j · GitHub](https://github.com/spring-projects/spring-data-neo4j/blob/e4450fdd9866ca7451f1cb8bee375cec532dcdf2/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/RestaurantTests.java#L500)

---

<div class="post-metadata">

### Author: ![moritz.loeser](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/moritz.loeser/32/2936_2.png) [@moritz.loeser](https://community.neo4j.com/u/moritz.loeser)
#### Post date: [February 13, 2019, 3:09pm UTC](https://community.neo4j.com/t/unable-to-ignore-case-of-java-lang-string-types-ignorecase-combined-with-contains-not-working/5041/5 "2019-02-13T15:09:10Z")

</div>

Just: Thank You 🙂
