DATAGRAPH-1407 - Make consistent use of mayBeReadWrite for deciding to clear the session or not.

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.
This commit is contained in:
Michael Simons
2020-11-04 15:58:14 +01:00
parent f585803253
commit 4b2cce1f39
2 changed files with 47 additions and 1 deletions

View File

@@ -41,7 +41,7 @@
<project.type>multi</project.type>
<neo4j.ogm.version>3.2.17</neo4j.ogm.version>
<neo4j.ogm.version>3.2.18</neo4j.ogm.version>
<springdata.commons>2.3.6.BUILD-SNAPSHOT</springdata.commons>
</properties>

View File

@@ -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<String> emailAddresses = new HashSet<>();