|
39 | 39 | import org.springframework.data.cassandra.core.mapping.*; |
40 | 40 | import org.springframework.data.cassandra.core.mapping.Embedded.OnEmpty; |
41 | 41 | import org.springframework.data.convert.CustomConversions; |
| 42 | +import org.springframework.data.mapping.AccessOptions; |
42 | 43 | import org.springframework.data.mapping.InstanceCreatorMetadata; |
43 | 44 | import org.springframework.data.mapping.MappingException; |
44 | 45 | import org.springframework.data.mapping.Parameter; |
45 | 46 | import org.springframework.data.mapping.PersistentEntity; |
46 | 47 | import org.springframework.data.mapping.PersistentProperty; |
47 | 48 | import org.springframework.data.mapping.PersistentPropertyAccessor; |
| 49 | +import org.springframework.data.mapping.PersistentPropertyPath; |
| 50 | +import org.springframework.data.mapping.PersistentPropertyPathAccessor; |
48 | 51 | import org.springframework.data.mapping.context.MappingContext; |
49 | 52 | import org.springframework.data.mapping.model.ConvertingPropertyAccessor; |
50 | 53 | import org.springframework.data.mapping.model.DefaultSpELExpressionEvaluator; |
@@ -283,6 +286,7 @@ private <T> Class<T> transformClassToBeanClassLoaderClass(Class<T> entity) { |
283 | 286 | } |
284 | 287 |
|
285 | 288 | @Override |
| 289 | + @SuppressWarnings("unchecked") |
286 | 290 | public <R> R project(EntityProjection<R, ?> projection, Row row) { |
287 | 291 |
|
288 | 292 | if (!projection.isProjection()) { |
@@ -665,7 +669,7 @@ private void writeWhereFromObject(Object source, Where sink, CassandraPersistent |
665 | 669 | ? getMappingContext().getRequiredPersistentEntity(compositeIdProperty) |
666 | 670 | : entity; |
667 | 671 |
|
668 | | - writeWhere(MapId.class.cast(id), sink, whereEntity); |
| 672 | + writeWhere((MapId) id, sink, whereEntity); |
669 | 673 | return; |
670 | 674 | } |
671 | 675 |
|
@@ -725,18 +729,6 @@ private void writeWhere(MapId id, Where sink, CassandraPersistentEntity<?> entit |
725 | 729 | } |
726 | 730 | } |
727 | 731 |
|
728 | | - private void writeWhere(ConvertingPropertyAccessor<?> accessor, Where sink, CassandraPersistentEntity<?> entity) { |
729 | | - |
730 | | - Assert.isTrue(entity.isCompositePrimaryKey(), |
731 | | - () -> String.format("Entity [%s] is not a composite primary key", entity.getName())); |
732 | | - |
733 | | - for (CassandraPersistentProperty property : entity) { |
734 | | - TypeCodec<Object> codec = getCodec(property); |
735 | | - Object value = accessor.getProperty(property, codec.getJavaType().getRawType()); |
736 | | - sink.put(property.getRequiredColumnName(), value); |
737 | | - } |
738 | | - } |
739 | | - |
740 | 732 | private void writeTupleValue(ConvertingPropertyAccessor<?> propertyAccessor, TupleValue tupleValue, |
741 | 733 | CassandraPersistentEntity<?> entity) { |
742 | 734 |
|
@@ -863,7 +855,7 @@ private Class<?> getTargetType(CassandraPersistentProperty property) { |
863 | 855 | */ |
864 | 856 | @Nullable |
865 | 857 | @SuppressWarnings("unchecked") |
866 | | - private <T> T getWriteValue(CassandraPersistentProperty property, ConvertingPropertyAccessor propertyAccessor) { |
| 858 | + private <T> T getWriteValue(CassandraPersistentProperty property, ConvertingPropertyAccessor<?> propertyAccessor) { |
867 | 859 |
|
868 | 860 | ColumnType cassandraTypeDescriptor = cassandraTypeResolver.resolve(property); |
869 | 861 |
|
@@ -914,7 +906,7 @@ private Object getWriteValue(@Nullable Object value, ColumnType columnType) { |
914 | 906 | return writeMapInternal((Map<Object, Object>) value, columnType); |
915 | 907 | } |
916 | 908 |
|
917 | | - TypeInformation<?> type = TypeInformation.of((Class) value.getClass()); |
| 909 | + TypeInformation<?> type = TypeInformation.of((Class<?>) value.getClass()); |
918 | 910 | TypeInformation<?> actualType = type.getRequiredActualType(); |
919 | 911 | BasicCassandraPersistentEntity<?> entity = getMappingContext().getPersistentEntity(actualType.getType()); |
920 | 912 |
|
@@ -989,7 +981,6 @@ private Object writeMapInternal(Map<Object, Object> source, ColumnType type) { |
989 | 981 | * @param requestedTargetType must not be {@literal null}. |
990 | 982 | * @see org.springframework.data.cassandra.core.mapping.CassandraType |
991 | 983 | */ |
992 | | - @SuppressWarnings("unchecked") |
993 | 984 | @Nullable |
994 | 985 | private Object getPotentiallyConvertedSimpleValue(@Nullable Object value, @Nullable Class<?> requestedTargetType) { |
995 | 986 |
|
@@ -1237,7 +1228,7 @@ public <T> T getParameterValue(Parameter<T, CassandraPersistentProperty> paramet |
1237 | 1228 | * Extension of {@link SpELExpressionParameterValueProvider} to recursively trigger value conversion on the raw |
1238 | 1229 | * resolved SpEL value. |
1239 | 1230 | */ |
1240 | | - private class ConverterAwareSpELExpressionParameterValueProvider |
| 1231 | + private static class ConverterAwareSpELExpressionParameterValueProvider |
1241 | 1232 | extends SpELExpressionParameterValueProvider<CassandraPersistentProperty> { |
1242 | 1233 |
|
1243 | 1234 | private final ConversionContext context; |
@@ -1450,16 +1441,8 @@ private CassandraPersistentProperty getPersistentProperty(String name, TypeInfor |
1450 | 1441 | } |
1451 | 1442 | } |
1452 | 1443 |
|
1453 | | - private static class PropertyTranslatingPropertyAccessor<T> implements PersistentPropertyPathAccessor<T> { |
1454 | | - |
1455 | | - private final PersistentPropertyAccessor<T> delegate; |
1456 | | - private final PersistentPropertyTranslator propertyTranslator; |
1457 | | - |
1458 | | - private PropertyTranslatingPropertyAccessor(PersistentPropertyAccessor<T> delegate, |
1459 | | - PersistentPropertyTranslator propertyTranslator) { |
1460 | | - this.delegate = delegate; |
1461 | | - this.propertyTranslator = propertyTranslator; |
1462 | | - } |
| 1444 | + private record PropertyTranslatingPropertyAccessor<T> (PersistentPropertyAccessor<T> delegate, |
| 1445 | + PersistentPropertyTranslator propertyTranslator) implements PersistentPropertyPathAccessor<T> { |
1463 | 1446 |
|
1464 | 1447 | static <T> PersistentPropertyAccessor<T> create(PersistentPropertyAccessor<T> delegate, |
1465 | 1448 | PersistentPropertyTranslator propertyTranslator) { |
@@ -1566,7 +1549,7 @@ static class MapPersistentPropertyAccessor implements PersistentPropertyAccessor |
1566 | 1549 | Map<String, Object> map = new LinkedHashMap<>(); |
1567 | 1550 |
|
1568 | 1551 | @Override |
1569 | | - public void setProperty(PersistentProperty<?> persistentProperty, Object o) { |
| 1552 | + public void setProperty(PersistentProperty<?> persistentProperty, @Nullable Object o) { |
1570 | 1553 | map.put(persistentProperty.getName(), o); |
1571 | 1554 | } |
1572 | 1555 |
|
|
0 commit comments