Skip to content

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