When activating Neo4jTransactionManager.setValidateExistingTransaction(true) a simple findById() will result in an IllegalStateException. This is due to getSingleResult() always executing in the default transactional-template
https://github.com/spring-projects/spring-data-neo4j/blob/main/src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java#L1277
whereas the outer call findById() executes in a readonly-transaction.
https://github.com/spring-projects/spring-data-neo4j/blob/main/src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java#L338
How to reproduce:
- activate transaction validation as described in @michael-simons tips (see below)
- call
findById() on a neo4j-template or -repository
See also