Skip to content

Commit 4b2cce1

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 f585803 commit 4b2cce1

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.3.6.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
@@ -673,6 +673,52 @@ public void findNoUserByNotContainingEmailAddresses() {
673673
assertThat(foundUser.isEmpty()).isTrue();
674674
}
675675

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

0 commit comments

Comments
 (0)