Skip to content

Throw exception upon returning Result in managed transaction API #1422

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

Merged
merged 1 commit into from
May 11, 2023

Conversation

injectives
Copy link
Contributor

@injectives injectives commented May 10, 2023

Returning Result (or ResultCursor, ReactiveResult, etc.) directly in the managed transaction API is an invalid use of the API and it should be avoided.

https://neo4j.com/docs/java-manual/current/session-api/#java-driver-simple-result-consume

Any query results obtained within a transaction function should be consumed within that function, as connection-bound resources cannot be managed correctly when out of scope. To that end, transaction functions can return values but these should be derived values rather than raw results.

@injectives injectives changed the title Throw exception upon returning result in managed transaction API Throw exception upon returning Result in managed transaction API May 10, 2023
@injectives injectives requested a review from gjmwoods May 10, 2023 14:01
Returning `Result` (or `ResultCursor`, `ReactiveResult`, etc.) directly in the managed transaction API is an invalid use of the API and it should be avoided.

https://neo4j.com/docs/java-manual/current/session-api/#java-driver-simple-result-consume
> Any query results obtained within a transaction function should be consumed within that function, as connection-bound resources cannot be managed correctly when out of scope. To that end, transaction functions can return values but these should be derived values rather than raw results.
@injectives injectives merged commit b19edb9 into neo4j:5.0 May 11, 2023
@injectives injectives deleted the feature/runtime branch May 11, 2023 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants