Browse Source

Polishing.

Add Geometry super-type only as subtypes are considered simple types already. Ensure reflective simple type AOT registration.

Original pull request: #1713
See #1711
3.1.x
Mark Paluch 2 years ago
parent
commit
30f7e82ea6
No known key found for this signature in database
GPG Key ID: 55BC6374BAA9D973
  1. 6
      spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/aot/R2dbcRuntimeHints.java
  2. 11
      spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/dialect/PostgresDialect.java

6
spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/aot/R2dbcRuntimeHints.java

@ -21,6 +21,7 @@ import org.springframework.aot.hint.MemberCategory; @@ -21,6 +21,7 @@ import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeReference;
import org.springframework.data.r2dbc.dialect.PostgresDialect;
import org.springframework.data.r2dbc.mapping.event.AfterConvertCallback;
import org.springframework.data.r2dbc.mapping.event.AfterSaveCallback;
import org.springframework.data.r2dbc.mapping.event.BeforeConvertCallback;
@ -31,6 +32,7 @@ import org.springframework.data.r2dbc.repository.support.SimpleR2dbcRepository; @@ -31,6 +32,7 @@ import org.springframework.data.r2dbc.repository.support.SimpleR2dbcRepository;
* {@link RuntimeHintsRegistrar} for R2DBC.
*
* @author Christoph Strobl
* @author Mark Paluch
* @since 3.0
*/
class R2dbcRuntimeHints implements RuntimeHintsRegistrar {
@ -45,5 +47,9 @@ class R2dbcRuntimeHints implements RuntimeHintsRegistrar { @@ -45,5 +47,9 @@ class R2dbcRuntimeHints implements RuntimeHintsRegistrar {
.of(BeforeConvertCallback.class),
TypeReference.of(BeforeSaveCallback.class), TypeReference.of(AfterSaveCallback.class)),
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS));
for (Class<?> simpleType : PostgresDialect.INSTANCE.simpleTypes()) {
hints.reflection().registerType(TypeReference.of(simpleType), MemberCategory.PUBLIC_CLASSES);
}
}
}

11
spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/dialect/PostgresDialect.java

@ -59,16 +59,7 @@ public class PostgresDialect extends org.springframework.data.relational.core.di @@ -59,16 +59,7 @@ public class PostgresDialect extends org.springframework.data.relational.core.di
.forEach(s -> ifClassPresent(s, simpleTypes::add));
// support the native JTS types supported by r2dbc-postgresql
Stream.of("org.locationtech.jts.geom.Geometry", //
"org.locationtech.jts.geom.Point", //
"org.locationtech.jts.geom.MultiPoint", //
"org.locationtech.jts.geom.LineString", //
"org.locationtech.jts.geom.LinearRing", //
"org.locationtech.jts.geom.MultiLineString", //
"org.locationtech.jts.geom.Polygon", //
"org.locationtech.jts.geom.MultiPolygon", //
"org.locationtech.jts.geom.GeometryCollection") //
.forEach(s -> ifClassPresent(s, simpleTypes::add));
ifClassPresent("org.locationtech.jts.geom.Geometry", simpleTypes::add);
// conditional Postgres JSON support.
ifClassPresent("io.r2dbc.postgresql.codec.Json", simpleTypes::add);

Loading…
Cancel
Save