@@ -52,15 +52,7 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
5252 builder -> builder .withMembers (MemberCategory .INVOKE_DECLARED_CONSTRUCTORS ,
5353 MemberCategory .INVOKE_PUBLIC_METHODS ));
5454
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- }
55+ registerTransactionProxyHints (hints , classLoader );
6456
6557 if (isReactorPresent ()) {
6658
@@ -73,4 +65,17 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
7365
7466 }
7567 }
68+
69+ private static void registerTransactionProxyHints (RuntimeHints hints , @ Nullable ClassLoader classLoader ) {
70+
71+ if (MongoAotPredicates .isSyncClientPresent (classLoader ) && ClassUtils .isPresent ("org.springframework.aop.SpringProxy" , classLoader )) {
72+
73+ hints .proxies ().registerJdkProxy (TypeReference .of ("com.mongodb.client.MongoDatabase" ),
74+ TypeReference .of ("org.springframework.aop.SpringProxy" ),
75+ TypeReference .of ("org.springframework.core.DecoratingProxy" ));
76+ hints .proxies ().registerJdkProxy (TypeReference .of ("com.mongodb.client.MongoCollection" ),
77+ TypeReference .of ("org.springframework.aop.SpringProxy" ),
78+ TypeReference .of ("org.springframework.core.DecoratingProxy" ));
79+ }
80+ }
7681}
0 commit comments