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

Getting warning about the deprecated id() function when using the @Id annotation. #2716

Closed
subhankardas opened this issue May 1, 2023 · 3 comments
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@subhankardas
Copy link

I am using the Neo4jRepository and @node entity with @id and @relationship to another node entity and getting an error saying:
023-05-02 00:59:57.789 WARN 17384 --- [ main] org.springframework.data.neo4j.cypher : Neo.ClientNotification.Statement.FeatureDeprecationWarning: This feature is deprecated and will be removed in future versions. OPTIONAL MATCH (hlp:Customer) WHERE id(hlp) = $__id__ WITH hlp WHERE hlp IS NULL CREATE (customer:Customer) SET customer = $__properties__ RETURN customer UNION MATCH (customer:Customer) WHERE id(customer) = $__id__ SET customer += $__properties__ RETURN customer ^ The query used a deprecated function. ('id' is no longer supported)
I am assuming this is due to the @id annotation which is internally using deprecated function, so is there any planned release for this fix?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 1, 2023
@meistermeier
Copy link
Collaborator

The id function for nodes and relationships got deprecated and was replaced with elementId in Neo4j 5. The warning itself just got harsher with Neo4j 5.6 (and should not mention ..no longer supported.. in one of the next minor releases). There is nothing to worry about right now. It's just the message not any misbehaving functionality in Spring Data Neo4j.
We are internally working on making use of elementId already but couldn't do it for Spring Data Neo4j 7 back in the days because Neo4j 5 got released later and the feature was not stable.
If you want to keep the warnings for Cypher enabled but mute those messages, here is a solution to do this: #2660 (comment)
If you have any further questions regarding this topic, please reopen this issue.

@subhankardas
Copy link
Author

Thanks for the help @meistermeier! :)

@meistermeier meistermeier pinned this issue May 2, 2023
michael-simons added a commit that referenced this issue May 4, 2023
…he users datamodel.

This change makes use of the Cypher-DSL dialect capatibilities and uses a String identifier internally for all objects. This will be the `elementId()` on Neo4j 5 and higher and `toString(id())` on Neo4j 4 and lower.

Unless explicitly configured by the user through having `@Id @GeneratedValue long id`, we don’t use the `id()` function anymore. This function has been deprecated in Neo4j 5.

Users are encouraged to use `@Id @GeneratedValue String id` for assigning the element id as object id or using custom unique identifiers or `@Id @GeneratedValue UUID id` or  `@Id @GeneratedValue(value = UUIDStringGenerator.class) String id` for UUIDs.

We marked the long ids as deprecated, but don’t have any plans for now to remove them, so that future SDN versions will still be compatible with older Neo4j versions if the data model contains long ids.

We opted for using String’s directly to avoid tons of additional instances and rely on the JVMs excellent String caching capatiblities, thus, the `ElementId` interface - not usable so far anyhow - has been removed without current or planned replacement.

See #2716 and other tickets, closes #2718.
@nkonev
Copy link

nkonev commented Jul 9, 2023

import org.neo4j.cypherdsl.core.renderer.Configuration;
import org.neo4j.cypherdsl.core.renderer.Dialect;
...
    @Bean
    Configuration cypherDslConfiguration() {
        return Configuration.newConfig().withDialect(Dialect.NEO4J_5).build();
    }

helped to eliminate the warning. From here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

4 participants