diff --git a/jpa/java8/pom.xml b/jpa/java8/pom.xml index 9685749f..39730779 100644 --- a/jpa/java8/pom.xml +++ b/jpa/java8/pom.xml @@ -10,5 +10,9 @@ spring-data-jpa-java8 Spring Data JPA - Java 8 specific features + + + Ingalls-BUILD-SNAPSHOT + \ No newline at end of file diff --git a/jpa/java8/src/test/java/example/springdata/jpa/java8/Java8IntegrationTests.java b/jpa/java8/src/test/java/example/springdata/jpa/java8/Java8IntegrationTests.java index 9a5afc7f..7227f9db 100644 --- a/jpa/java8/src/test/java/example/springdata/jpa/java8/Java8IntegrationTests.java +++ b/jpa/java8/src/test/java/example/springdata/jpa/java8/Java8IntegrationTests.java @@ -30,6 +30,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -106,6 +107,16 @@ public class Java8IntegrationTests { } } + /** + * Query methods using streaming need to be used inside a surrounding transaction to keep the connection open while + * the stream is consumed. We simulate that not being the case by actively disabling the transaction here. + */ + @Test(expected = InvalidDataAccessApiUsageException.class) + @Transactional(propagation = Propagation.NOT_SUPPORTED) + public void rejectsStreamExecutionIfNoSurroundingTransactionActive() { + repository.findAllByLastnameIsNotNull(); + } + /** * Here we demonstrate the usage of {@link CompletableFuture} as a result wrapper for asynchronous repository query * methods. Note, that we need to disable the surrounding transaction to be able to asynchronously read the written