Skip to content

Don't resolve circular possible circular relationships for queries returning count or exists projections. #2157

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

Closed
martin-salinger opened this issue Feb 18, 2021 · 3 comments
Assignees
Labels
type: bug A general bug

Comments

@martin-salinger
Copy link

Hi,

with version 6.0.4 and 6.0.5 a derived count query like
long countByLastname(String lastname);
throws an AopInvocationException:
org.springframework.aop.AopInvocationException: Null return value from advice does not match primitive return type

The reason is an incorrectly generated cypher query:
MATCH ... WITH collect(id(n)) AS __sn__ RETURN __sn__

With version 6.0.3 (and before) the cypher query is generated correctly:
MATCH ... RETURN count(*)

BTW: Thanks a lot for the great work!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 18, 2021
@michael-simons
Copy link
Collaborator

I can confirm this bug.

michael-simons added a commit that referenced this issue Feb 18, 2021
@michael-simons michael-simons added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 18, 2021
@michael-simons michael-simons added this to the 6.0.6 (2020.0.6) milestone Feb 18, 2021
@michael-simons
Copy link
Collaborator

This will be fixed in the next patch.

We are sorry for causing you issues. The root cause is to be related in the much improved querying of cycling mapping, which get's triggered by your mapping.

To mitigate the issue, you can use

@Query(value = "MATCH (n:Label {lastname: $lastname}) RETURN count(n)", count = true)
long countByLastname(String lastname);

or

@Query(value = "MATCH (n:Label {lastname: $lastname}) RETURN count(n) > 0", exists = true)
long existByLastname(String lastname);

(exists being affected as well).

michael-simons added a commit that referenced this issue Feb 18, 2021
@michael-simons michael-simons changed the title Derived count query throws AopInvocationException Don't resolve circular possible circular relationships for queries returning count or exists projections. Feb 18, 2021
@martin-salinger
Copy link
Author

Thank you for the custom query to mitigate the issue!

It´s good to hear that the querying of cycling mapping has been much improved 👍

meistermeier added a commit that referenced this issue Feb 19, 2021
meistermeier added a commit that referenced this issue Feb 19, 2021
michael-simons added a commit that referenced this issue Feb 19, 2021
…queries returning count or exists projections.

This fixes #2157
Original pull request:  #2158.

Co-authored-by: Gerrit Meier <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants