Skip to content

Commit 4db8179

Browse files
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.
1 parent a35f1af commit 4db8179

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
<project.type>multi</project.type>
4343

44-
<neo4j.ogm.version>3.2.17</neo4j.ogm.version>
44+
<neo4j.ogm.version>3.2.18</neo4j.ogm.version>
4545
<springdata.commons>2.2.12.BUILD-SNAPSHOT</springdata.commons>
4646
</properties>
4747

spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/MoviesIntegrationTests.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,52 @@ public void findNoUserByNotContainingEmailAddresses() {
670670
assertTrue(foundUser.isEmpty());
671671
}
672672

673+
@Test // DATAGRAPH-1407
674+
public void shouldRemoveGenreFromUserDespiteReadonlyCustomQuery() {
675+
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
676+
@Override
677+
public void doInTransactionWithoutResult(TransactionStatus status) {
678+
User michal = new User("Michal");
679+
Genre drama = new Genre("Drama");
680+
michal.interestedIn(drama);
681+
682+
userRepository.save(michal);
683+
684+
michal.notInterestedIn(drama);
685+
686+
userRepository.getAllUsers();
687+
userRepository.save(michal);
688+
}
689+
});
690+
691+
assertThat(graphDatabaseService)
692+
.containsNode("MATCH (m:User:Person {name:'Michal'})," + "(g:Genre {name:'Drama'})" +
693+
" WHERE NOT (m)-[:INTERESTED]->(g) RETURN m AS n");
694+
}
695+
696+
@Test // DATAGRAPH-1407
697+
public void shouldRemoveGenreFromUserDespiteReadonlyCustomQueryWithQueryResult() {
698+
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
699+
@Override
700+
public void doInTransactionWithoutResult(TransactionStatus status) {
701+
User michal = new User("Michal");
702+
Genre drama = new Genre("Drama");
703+
michal.interestedIn(drama);
704+
705+
userRepository.save(michal);
706+
707+
michal.notInterestedIn(drama);
708+
709+
userRepository.retrieveAllUsersAndTheirAges();
710+
userRepository.save(michal);
711+
}
712+
});
713+
714+
assertThat(graphDatabaseService)
715+
.containsNode("MATCH (m:User:Person {name:'Michal'})," + "(g:Genre {name:'Drama'})" +
716+
" WHERE NOT (m)-[:INTERESTED]->(g) RETURN m AS n");
717+
}
718+
673719
private void createUserForContainsTest() {
674720
User user = new User("Somebody");
675721
Set<String> emailAddresses = new HashSet<>();

0 commit comments

Comments
 (0)