DATAGRAPH-1249 - Ensure flushing the mapping context on potentially generic write queries.
This commits adds two tests ensuring that OGM 3.2.15 and 3.1.21 actually flushes the mapping context after a potential write query is executed which doesn’t involve any cached `NodeEntity` or `RelationshipEntity`.
This commit is contained in:
@@ -54,6 +54,12 @@ public interface UserRepository extends PersonRepository<User, Long> {
|
||||
|
||||
List<User> findByRatingsStarsIgnoreCase(int stars);
|
||||
|
||||
@Query("MATCH (c:User) SET c.surname = 'Helge' RETURN c")
|
||||
List<User> bulkUpdateReturningNode();
|
||||
|
||||
@Query("MATCH (c:User) SET c.surname = 'Helge'")
|
||||
void bulkUpdateNoReturn();
|
||||
|
||||
@Query("MATCH (user:User) RETURN COUNT(user)")
|
||||
int findTotalUsers();
|
||||
|
||||
|
||||
@@ -769,4 +769,36 @@ public class QueryIntegrationTests {
|
||||
transaction.success();
|
||||
}
|
||||
}
|
||||
|
||||
@Test // DATAGRAPH-1249
|
||||
public void shouldFlushSessionAfterBulkUpdateReturningNodes() {
|
||||
|
||||
executeUpdate("CREATE (:User {name:'Schneider'}), (:User {name:'Hundingsbane'})");
|
||||
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
assertThat(userRepository.findAll()).hasSize(2);
|
||||
|
||||
assertThat(userRepository.bulkUpdateReturningNode()).extracting(User::getSurname).containsOnly("Helge");
|
||||
|
||||
assertThat(userRepository.findAll()).extracting(User::getSurname).containsOnly("Helge");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test // DATAGRAPH-1249
|
||||
public void shouldFlushSessionAfterBulkUpdateWithoutNodes() {
|
||||
|
||||
executeUpdate("CREATE (:User {name:'Schneider'}), (:User {name:'Hundingsbane'})");
|
||||
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
assertThat(userRepository.findAll()).hasSize(2);
|
||||
|
||||
userRepository.bulkUpdateNoReturn();
|
||||
|
||||
assertThat(userRepository.findAll()).extracting(User::getSurname).containsOnly("Helge");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user