From 4b2cce1f394575d6601062208a514d3163ca9813 Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Wed, 4 Nov 2020 15:58:14 +0100 Subject: [PATCH] DATAGRAPH-1407 - Make consistent use of mayBeReadWrite for deciding to clear the session or not. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This updates to Neo4j-OGM 3.2.18 and ensures that read only queries don’t clear the session and in the process of doing that would prevent legit updates to relationships. --- pom.xml | 2 +- .../movies/MoviesIntegrationTests.java | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dbb1fd6b6..69fd3d8c0 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ multi - 3.2.17 + 3.2.18 2.3.6.BUILD-SNAPSHOT diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/MoviesIntegrationTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/MoviesIntegrationTests.java index 3c19e4cd2..1084072b3 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/MoviesIntegrationTests.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/MoviesIntegrationTests.java @@ -673,6 +673,52 @@ public class MoviesIntegrationTests { assertThat(foundUser.isEmpty()).isTrue(); } + @Test // DATAGRAPH-1407 + public void shouldRemoveGenreFromUserDespiteReadonlyCustomQuery() { + transactionTemplate.execute(new TransactionCallbackWithoutResult() { + @Override + public void doInTransactionWithoutResult(TransactionStatus status) { + User michal = new User("Michal"); + Genre drama = new Genre("Drama"); + michal.interestedIn(drama); + + userRepository.save(michal); + + michal.notInterestedIn(drama); + + userRepository.getAllUsers(); + userRepository.save(michal); + } + }); + + assertThat(graphDatabaseService) + .containsNode("MATCH (m:User:Person {name:'Michal'})," + "(g:Genre {name:'Drama'})" + + " WHERE NOT (m)-[:INTERESTED]->(g) RETURN m AS n"); + } + + @Test // DATAGRAPH-1407 + public void shouldRemoveGenreFromUserDespiteReadonlyCustomQueryWithQueryResult() { + transactionTemplate.execute(new TransactionCallbackWithoutResult() { + @Override + public void doInTransactionWithoutResult(TransactionStatus status) { + User michal = new User("Michal"); + Genre drama = new Genre("Drama"); + michal.interestedIn(drama); + + userRepository.save(michal); + + michal.notInterestedIn(drama); + + userRepository.retrieveAllUsersAndTheirAges(); + userRepository.save(michal); + } + }); + + assertThat(graphDatabaseService) + .containsNode("MATCH (m:User:Person {name:'Michal'})," + "(g:Genre {name:'Drama'})" + + " WHERE NOT (m)-[:INTERESTED]->(g) RETURN m AS n"); + } + private void createUserForContainsTest() { User user = new User("Somebody"); Set emailAddresses = new HashSet<>();