Daniel
Daniel

Reputation: 6491

Spring CrudRepository - find ignore case in collection

I figured since the syntax for an ignore case query is:

findByFieldIgnoreCase(Object field)

And the syntax for a collection query is

findByFieldIn(List<Object> fields)

The syntax for an ignore case collection query would be:

findByFieldIgnoreCaseIn(List<Object> fields)

But that doesn't seem to work (it's still case sensitive).

Ideas?

EDIT:

It's not findByFieldInIgnoreCase as well.

Upvotes: 1

Views: 2735

Answers (2)

rajadilipkolli
rajadilipkolli

Reputation: 3601

findByFieldInAndIgnoreCase(List<Object> fields)

This should work its not throwing any error while starting application.

Upvotes: 0

Marc Tarin
Marc Tarin

Reputation: 3169

The Spring Data MongoDB Reference Documentation states that:

The method parser supports setting an IgnoreCase flag for individual properties (for example, findByLastnameIgnoreCase(…)) or for all properties of a type that support ignoring case (usually String instances, for example, findByLastnameAndFirstnameAllIgnoreCase(…)). Whether ignoring cases is supported may vary by store, so consult the relevant sections in the reference documentation for the store-specific query method.

The table of supported keywords for query methods does not explicitly mention an InIgnoreCase or IgnoreCaseIn keyword.

As for other unsupported keywords, you can open a feature request on the Spring Data MongoDB JIRA.

In the mean time, to get your code running, you can implement your own findByFieldIgnoreCaseIn of findByFieldInIgnoreCase using the Query annotation or Querydsl. I offered several possible solutions for a similar case in this other post.

Upvotes: 1

Related Questions