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:
2
pom.xml
2
pom.xml
@@ -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>
|
||||
|
||||
|
||||
@@ -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<>();
|
||||
|
||||
Reference in New Issue
Block a user