Skip to content

Commit 88ea57f

Browse files
Provide native hints to create transaction proxies at runtime.
Closes: spring-projects#4221
1 parent 521bbd2 commit 88ea57f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/aot/MongoRuntimeHints.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.springframework.data.mongodb.core.mapping.event.ReactiveBeforeConvertCallback;
3333
import org.springframework.data.mongodb.core.mapping.event.ReactiveBeforeSaveCallback;
3434
import org.springframework.lang.Nullable;
35+
import org.springframework.util.ClassUtils;
3536

3637
/**
3738
* {@link RuntimeHintsRegistrar} for repository types and entity callbacks.
@@ -51,6 +52,16 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
5152
builder -> builder.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
5253
MemberCategory.INVOKE_PUBLIC_METHODS));
5354

55+
if (ClassUtils.isPresent("org.springframework.aop.SpringProxy", classLoader)) {
56+
57+
hints.proxies().registerJdkProxy(TypeReference.of(com.mongodb.client.MongoDatabase.class),
58+
TypeReference.of("org.springframework.aop.SpringProxy"),
59+
TypeReference.of("org.springframework.core.DecoratingProxy"));
60+
hints.proxies().registerJdkProxy(TypeReference.of(com.mongodb.client.MongoCollection.class),
61+
TypeReference.of("org.springframework.aop.SpringProxy"),
62+
TypeReference.of("org.springframework.core.DecoratingProxy"));
63+
}
64+
5465
if (isReactorPresent()) {
5566

5667
hints.reflection()

0 commit comments

Comments
 (0)