Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IgnoreCase does not work in Kotlin [DATAGRAPH-1200] #1762

spring-projects-issues opened this issue Feb 19, 2019 · 2 comments

IgnoreCase does not work in Kotlin [DATAGRAPH-1200] #1762

spring-projects-issues opened this issue Feb 19, 2019 · 2 comments


Copy link

@spring-projects-issues spring-projects-issues commented Feb 19, 2019

manuelprinz opened DATAGRAPH-1200 and commented

When creating a repository interface in Kotlin, using IgnoreCase will fail with the following error message:

Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Unable to ignore case of java.lang.String types, the property 'label' must reference a String; nested exception is java.lang.IllegalStateException: Unable to ignore case of java.lang.String types, the property 'label' must reference a String

This seems to be due to the compiled class being a kotlin.String instead of java.lang.String.

Using Kotlin strings in NodeEntities seems to work fine, so I expected these types of strings being equivalent everywhere.


interface FooRepository {
    fun findAllByLabelIgnoreCase(label: String): Iterable<Foo>

Please get back to me if you need more information or examples!

Affects: 5.1.5 (Lovelace SR5)

Copy link

@spring-projects-issues spring-projects-issues commented Feb 22, 2019

Gerrit Meier commented

Thanks for reporting this. It would be really helpful to get an example that reproduces the error you are facing.
Simply creating a domain class and repository with a method you mentioned above does work for me.
This is probably not the nicest Kotlin code ever written, but should match what you are targeting:

interface PersonRepository : Neo4jRepository<Person, Long> {
    fun findByNameIgnoreCase(label: String): List<Person>

class Person(var name: String) {
    var id: Long? = null

@ContextConfiguration(classes = [KotlinIntegrationTest.Config::class])
open class KotlinIntegrationTest {
    lateinit var repository: PersonRepository

    fun firstKotlinTest() {
        val name = "personsName"
        val person = Person(name)

        val result = repository.findByNameIgnoreCase(name)

    internal open class Config {
        open fun transactionManager(): PlatformTransactionManager {
            return Neo4jTransactionManager(sessionFactory())

        open fun sessionFactory(): SessionFactory {
            return SessionFactory(
                            .credentials("neo4j", "neo4j")

Copy link

@michael-simons michael-simons commented Jan 12, 2021

Hi @manuelprinz. I hope this is you. If not, sorry and please ignore the notification.

If you trying to match by the label of a node, this is not gonna work through derived finder methods. You can do this with a custom query around the following idea:

match (n) where any (label IN labels(n) WHERE toLower(label) = 'movie') return n

Here: All nodes that have a label movie. Of course all string operations, like regex etc, can be applied as well.

For the example @meistermeier added above, find the project attached. I tested it with 5.1.x, 5.2.x and 5.3.x (through Spring Boot 2.1.x, 2.2.x and 2.3.x), works as expected.

Thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants