SDN 6 custom query returns NULL

Hi there,

I am tring to return the subset of a domain entity (e.g ItemEntity) with a costom query using SDN 6 and SpringBoot 2.5. It is returning NULL without any error when I run the application.

I tried the same query in Neo4j Browser and works fine.

How that issue could be solved?

Below is a sample of the code where I face this issue

Thanks in advance for your help.



import java.util.Date;
import java.util.List;

public interface ItemRepository extends Neo4jRepository<ItemEntity, Integer> {

    @Query("MATCH (i:Item)"
            + " WHERE toLower (COALESCE(i.firstField,\" \")"
            + ") CONTAINS $englishKeyword"
            + " OR "
            + "COALESCE(i.secondField,\" \")"
            + "CONTAINS $russianKeyword"
            + " RETURN i"
    List<ItemSubset> findWithKeywords(String englishKeyword, String russianKeyword);

Would be really helpful to see your domain entity ItemEntity and the ItemSubset.
ItemSubset should be a valid projection as defined here reference documentation | projections.

Does this really return null or an empty list?

Hi @gerrit.meier

Thank you for your quick respond.

It returns an empty JSON Array. Something like [ ].

Please find code sample below:


import lombok.AllArgsConstructor;
import lombok.Data;

import java.time.LocalDate;

public class ItemEntity {
    private final Integer id;
    private final LocalDate active_date;
    private final String firstField;
    private final String secondField;
    private final String thirdField;
    @Relationship(type = "HANDLED_BY")
    private final TaskEntity task;



public interface ItemSubset {
    Integer getId();
    String getFirstField();
    String getSecondField();

Many thanks,

Could you checkout my example: neo4j-issues-examples/discourse-42200 at master · meistermeier/neo4j-issues-examples · GitHub
This works for me.

In your custom query you use toLower only on the english part not on the russian one. Might this be a problem?

Thank you @gerrit.meier !
I have changed the custom query based on your suggestion but I still have the sam problem (no data returned).

How can I work around this problem?

Many thanks,

    @Query("MATCH (i:Item)"
            + " WHERE toLower (COALESCE(i.e_ops,\" \")"
            + ") CONTAINS $englishKeyword"
            + " OR "
            + "toLower (COALESCE(i.r_ops,\" \")"
            + ") CONTAINS $russianKeyword"
            + " RETURN i"
    List<ItemSubset> findVariousKeywords(String englishKeyword, String russianKeyword);

I don't know what you are doing different to my example.
Maybe you can spot the difference between my code and your application around this place where you are facing the issue.

Thank you @gerrit.meier .

I have checked the example and changed the spring-boot-strarter-parent version from 2.5.0 to 2.5.3.

        <version>2.5.3</version> <!-- it was 2.5.0 -->
        <relativePath/> <!-- lookup parent from repository -->

It is working now. I do not know how this upgrade was related to my issue!!!