From c9123c66c7ec93e4f96042b8b6f9c74655d98647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6berl?= Date: Tue, 4 Jul 2023 17:19:02 +0200 Subject: [PATCH] Test that JPA repositories work when called in an init method See oracle/graalvm-reachability-metadata#324 and spring-projects/spring-framework#31050 See gh-183 --- .../com/example/data/jpa/AppInitializer.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 data/data-jpa/src/main/java/com/example/data/jpa/AppInitializer.java diff --git a/data/data-jpa/src/main/java/com/example/data/jpa/AppInitializer.java b/data/data-jpa/src/main/java/com/example/data/jpa/AppInitializer.java new file mode 100644 index 00000000..81b5051c --- /dev/null +++ b/data/data-jpa/src/main/java/com/example/data/jpa/AppInitializer.java @@ -0,0 +1,20 @@ +package com.example.data.jpa; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.stereotype.Service; + +@Service +public class AppInitializer implements InitializingBean { + + private AuthorRepository authorRepository; + + public AppInitializer(AuthorRepository authorRepository) { + this.authorRepository = authorRepository; + } + + @Override + public void afterPropertiesSet() throws Exception { + authorRepository.findByNameContainingIgnoreCase("name"); + } + +} \ No newline at end of file