The query used a deprecated function: `id`

Hello, greetings.

I have a problem in spring boot, and it is that I have the logs full of these messages:

The query used a deprecated function: id.
2023-09-06T15:45:20.817+02:00 WARN 466208 --- [o-auto-1-exec-3] org.springframework.data.neo4j.cypher : Neo.ClientNotification.Statement.FeatureDeprecationWarning: This feature is deprecated and will be removed in future versions.

for all my queries and I don't know what to do because it even comes out for this query:

         @Query("""
                         match (p:Post) - [:PUBLISHED_BY] -> (u:UserApp {id : $user_id})
                         return p
                                 """)
         List<Post> findAllByUserId(String user_id);

Cordially greetings

1 Like

I wonder if it thinks you are using id(node) instead of it being a variable name. Have you tried to change it from id to something else (e.g., userID) to see if you get the same behavior?

There is a previous post where we were told to create the following bean and it would suppress the warning. It worked for me with springboot 3.1.1, but reappeared when I tried 3.1.2.

  @Bean
    Configuration cypherDslConfiguration() {
        return Configuration.newConfig().withDialect(Dialect.NEO4J_5).build();
    }
2 Likes

@glilienfield I am having the same issue. Have you figured this out?

I was able to resolve the problem with the bean definition, but it only worked for springboot 3.1.1. The warnings came back when I upgraded to 3.1.3.

I have the same issue using 3.2.2 (and spring-data-neo4j 7.2.2):

2024-02-15T12:20:32.238-08:00  WARN 37512 --- [o4jDriverIO-3-5] o.s.data.neo4j.cypher.deprecation        : Neo.ClientNotification.Statement.FeatureDeprecationWarning: This feature is deprecated and will be removed in future versions.
	MATCH (startNode:`Node`)-[rel:`LINKS`]->(:`Node`) WHERE (startNode.uuid = $fromId AND NOT (id(rel) IN $__knownRelationShipIds__)) DELETE rel
	                                                                                           ^
The query used a deprecated function: `id`.
2024-02-15T12:20:32.262-08:00  WARN 37512 --- [o4jDriverIO-3-5] o.s.data.neo4j.cypher.deprecation        : Neo.ClientNotification.Statement.FeatureDeprecationWarning: This feature is deprecated and will be removed in future versions.
	MATCH (startNode:`Node`) WHERE startNode.uuid = $fromId MATCH (endNode) WHERE elementId(endNode) = $toId CREATE (startNode)-[relProps:`LINKS`]->(endNode) SET relProps += $__properties__ RETURN id(relProps) AS __internalNeo4jId__, elementId(relProps) AS __elementId__
	                                                                                                                                                                                                 ^
The query used a deprecated function: `id`.
2024-02-15T12:20:32.268-08:00  WARN 37512 --- [o4jDriverIO-3-5] o.s.data.neo4j.cypher.deprecation        : Neo.ClientNotification.Statement.FeatureDeprecationWarning: This feature is deprecated and will be removed in future versions.
	MATCH (startNode:`Node`)-[rel:`LINKS`]->(:`Node`) WHERE (startNode.uuid = $fromId AND NOT (id(rel) IN $__knownRelationShipIds__)) DELETE rel
	                                                                                           ^
The query used a deprecated function: `id`.
2024-02-15T12:20:32.279-08:00  WARN 37512 --- [o4jDriverIO-3-5] o.s.data.neo4j.cypher.deprecation        : Neo.ClientNotification.Statement.FeatureDeprecationWarning: This feature is deprecated and will be removed in future versions.
	MATCH (startNode:`Node`) WHERE startNode.uuid = $fromId MATCH (endNode) WHERE elementId(endNode) = $toId CREATE (startNode)-[relProps:`LINKS`]->(endNode) SET relProps += $__properties__ RETURN id(relProps) AS __internalNeo4jId__, elementId(relProps) AS __elementId__
	              
...

I do have this bean configured, which I believe is being observed because I receive a duplication error if I define the same bean in another place (crude gut check):


    @Bean
    Configuration cypherDslConfiguration() {
        return Configuration.newConfig()
                .withDialect(Dialect.NEO4J_5).build();
    }

Am I doing something wrong?

In my previous post I stated version 3.1.1 resolved the issue (with the bean definition), but it reappeared when I upgraded to 3.1.2. I just tried 3.1.3 and it appears.

I also just tried 3.2.1 and 3.2.2. The warnings were not generated with both versions. I see the version of SDN brought in from spring-boot-starter-data-neo4j:3.2.2 is spring-data-neo4j:7.2.2, so mine looks the same as yours. My Configuration bean is also created the same as what you have posted.

I am sure you are doing it, but is the bean defined in a spring component?

Thanks for testing, Gary.

I think I'm defining the bean within a Spring component, but I'm new to the ecosystem and could very well be doing it wrong:

@org.springframework.context.annotation.Configuration
public class Neo4jConfig {

    @Bean
    Configuration cypherDslConfiguration() {
        return Configuration.newConfig()
                .withDialect(Dialect.NEO4J_5).build();
    }

    // see: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.4.0-M2-Release-Notes#neo4j-1
    @Bean(ReactiveNeo4jRepositoryConfigurationExtension.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME)
    public ReactiveTransactionManager reactiveTransactionManager(
            Driver driver,
            ReactiveDatabaseSelectionProvider databaseNameProvider) {
        return new ReactiveNeo4jTransactionManager(driver, databaseNameProvider);
    }
}

The second bean is being properly observed.

Is there perhaps a way to inspect the active configuration at runtime to observe the effective Cypher dialect?

Well, you have the configuration class correctly annotated. The other thing to ensure is that the configuration class is within the auto component scan directories or specified as a configuration class. Considering your other bean in the class is working, you can assume one of those is true.

I autowired the bean in my controller class and set a break point so I could view the instance of the cypher dsl configuration class. Below is a screenshot. As shown, the dialect set to NEO4J_5.

Sorry, this was my mistake — I was using a Long as a @RelationshipId, which was causing the Cypher calls to id().

Somewhat interestingly, in my original post, we can also see elementId() calls in the same queries (for the nodes, which were using String IDs).

In case this is helpful to anyone else, I did verify my configured Cypher dialect using this:

@Component
public class CypherDslConfigInspector {

    @Autowired
    public CypherDslConfigInspector(MyNeo4jConfig config) {
        Configuration cypherDslConfiguration = config.cypherDslConfiguration();
        Dialect dialect = cypherDslConfiguration.getDialect();

        System.out.println("Cypher DSL Configuration Dialect: " + dialect.name());
    }
}

Thanks again for taking the time to help, Gary.

1 Like

I have kind of a similar issue.
I was following the official tutorial, to connect from python to Neo4J. Using Neo4j from Python - Getting Started . When I do the call to the class and its method I get the following:

Received notification from DBMS server: {severity: WARNING} {code: Neo.ClientNotification.Statement.FeatureDeprecationWarning} {category: DEPRECATION} {title: This feature is deprecated and will be removed in future versions.} {description: The query used a deprecated function: `id`.} {position: line: 1, column: 82, offset: 81} for query: "CREATE (a:Greeting) SET a.message = $message RETURN a.message + ', from node ' + id(a)"
hello, world, from node 0

I think is a related issue. If not, please let me know and I will open another ticket. I am using Neo4J 5.24.2 in Ubuntu 22.04.5 LTS