Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Commit 1064234

Browse files
christophstroblsdeleuze
authored andcommitted
Fix missing proxy configuration for spring data repositories annotated with Component
We require the additional proxy configuration (including java.io.Serializable) if the target repository is annotated with eg. org.springframework.stereotype.Repository because generated proxies extend Proxy and Proxy implements Serializable.
1 parent 33f7956 commit 1064234

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spring-graalvm-native-configuration/src/main/java/org/springframework/data/SpringDataComponentProcessor.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ private void registerRepositoryInterface(Type repositoryType, NativeImageContext
203203
// transactional
204204
imageContext.addProxy(repositoryType.getDottedName(), repositoryName, "org.springframework.transaction.interceptor.TransactionalProxy",
205205
"org.springframework.aop.framework.Advised", "org.springframework.core.DecoratingProxy");
206+
207+
/*
208+
* Generated proxies extend Proxy and Proxy implements Serializable. So the call:
209+
* protected void evaluateProxyInterfaces(Class<?> beanClass, ProxyFactory proxyFactory) {
210+
* Class<?>[] targetInterfaces = ClassUtils.getAllInterfacesForClass(beanClass, getProxyClassLoader());
211+
* is going to find targetInterfaces contains Serializable when called on the beanClass.
212+
*/
213+
if (repositoryType.isAtComponent()) {
214+
imageContext.addProxy(repositoryType.getDottedName(), repositoryName, "org.springframework.transaction.interceptor.TransactionalProxy",
215+
"org.springframework.aop.framework.Advised", "org.springframework.core.DecoratingProxy", "java.io.Serializable");
216+
}
206217
}
207218

208219
// reactive repo

0 commit comments

Comments
 (0)