diff --git a/src/main/java/org/springframework/data/r2dbc/function/DefaultReactiveDataAccessStrategy.java b/src/main/java/org/springframework/data/r2dbc/function/DefaultReactiveDataAccessStrategy.java index 8a5b9bd14..c6d52cab4 100644 --- a/src/main/java/org/springframework/data/r2dbc/function/DefaultReactiveDataAccessStrategy.java +++ b/src/main/java/org/springframework/data/r2dbc/function/DefaultReactiveDataAccessStrategy.java @@ -27,11 +27,11 @@ import java.util.stream.Collectors; import org.springframework.data.convert.EntityInstantiators; import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Order; -import org.springframework.data.jdbc.core.mapping.JdbcMappingContext; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentProperty; import org.springframework.data.mapping.PersistentPropertyAccessor; import org.springframework.data.r2dbc.function.convert.EntityRowMapper; +import org.springframework.data.relational.core.mapping.RelationalMappingContext; +import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; +import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; import org.springframework.data.util.Pair; import org.springframework.data.util.StreamUtils; import org.springframework.util.ClassUtils; @@ -41,14 +41,14 @@ import org.springframework.util.ClassUtils; */ public class DefaultReactiveDataAccessStrategy implements ReactiveDataAccessStrategy { - private final JdbcMappingContext mappingContext; + private final RelationalMappingContext mappingContext; private final EntityInstantiators instantiators; public DefaultReactiveDataAccessStrategy() { - this(new JdbcMappingContext(), new EntityInstantiators()); + this(new RelationalMappingContext(), new EntityInstantiators()); } - public DefaultReactiveDataAccessStrategy(JdbcMappingContext mappingContext, EntityInstantiators instantiators) { + public DefaultReactiveDataAccessStrategy(RelationalMappingContext mappingContext, EntityInstantiators instantiators) { this.mappingContext = mappingContext; this.instantiators = instantiators; } @@ -56,14 +56,14 @@ public class DefaultReactiveDataAccessStrategy implements ReactiveDataAccessStra @Override public List getAllFields(Class typeToRead) { - JdbcPersistentEntity persistentEntity = mappingContext.getPersistentEntity(typeToRead); + RelationalPersistentEntity persistentEntity = mappingContext.getPersistentEntity(typeToRead); if (persistentEntity == null) { return Collections.singletonList("*"); } return StreamUtils.createStreamFromIterator(persistentEntity.iterator()) // - .map(JdbcPersistentProperty::getColumnName) // + .map(RelationalPersistentProperty::getColumnName) // .collect(Collectors.toList()); } @@ -72,12 +72,12 @@ public class DefaultReactiveDataAccessStrategy implements ReactiveDataAccessStra Class userClass = ClassUtils.getUserClass(object); - JdbcPersistentEntity entity = mappingContext.getRequiredPersistentEntity(userClass); + RelationalPersistentEntity entity = mappingContext.getRequiredPersistentEntity(userClass); PersistentPropertyAccessor propertyAccessor = entity.getPropertyAccessor(object); List> values = new ArrayList<>(); - for (JdbcPersistentProperty property : entity) { + for (RelationalPersistentProperty property : entity) { Object value = propertyAccessor.getProperty(property); @@ -94,7 +94,7 @@ public class DefaultReactiveDataAccessStrategy implements ReactiveDataAccessStra @Override public Sort getMappedSort(Class typeToRead, Sort sort) { - JdbcPersistentEntity entity = mappingContext.getPersistentEntity(typeToRead); + RelationalPersistentEntity entity = mappingContext.getPersistentEntity(typeToRead); if (entity == null) { return sort; } @@ -103,7 +103,7 @@ public class DefaultReactiveDataAccessStrategy implements ReactiveDataAccessStra for (Order order : sort) { - JdbcPersistentProperty persistentProperty = entity.getPersistentProperty(order.getProperty()); + RelationalPersistentProperty persistentProperty = entity.getPersistentProperty(order.getProperty()); if (persistentProperty == null) { mappedOrder.add(order); } else { @@ -117,7 +117,7 @@ public class DefaultReactiveDataAccessStrategy implements ReactiveDataAccessStra @Override public BiFunction getRowMapper(Class typeToRead) { - return new EntityRowMapper((JdbcPersistentEntity) mappingContext.getRequiredPersistentEntity(typeToRead), + return new EntityRowMapper((RelationalPersistentEntity) mappingContext.getRequiredPersistentEntity(typeToRead), instantiators, mappingContext); } diff --git a/src/main/java/org/springframework/data/r2dbc/function/convert/EntityRowMapper.java b/src/main/java/org/springframework/data/r2dbc/function/convert/EntityRowMapper.java index 7d21d3454..22f45c63f 100644 --- a/src/main/java/org/springframework/data/r2dbc/function/convert/EntityRowMapper.java +++ b/src/main/java/org/springframework/data/r2dbc/function/convert/EntityRowMapper.java @@ -25,9 +25,6 @@ import java.util.function.BiFunction; import org.springframework.core.convert.ConversionService; import org.springframework.data.convert.EntityInstantiators; -import org.springframework.data.jdbc.core.mapping.JdbcMappingContext; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentProperty; import org.springframework.data.mapping.MappingException; import org.springframework.data.mapping.PersistentProperty; import org.springframework.data.mapping.PersistentPropertyAccessor; @@ -35,6 +32,9 @@ import org.springframework.data.mapping.PreferredConstructor.Parameter; import org.springframework.data.mapping.context.MappingContext; import org.springframework.data.mapping.model.ConvertingPropertyAccessor; import org.springframework.data.mapping.model.ParameterValueProvider; +import org.springframework.data.relational.core.mapping.RelationalMappingContext; +import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; +import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; import org.springframework.util.ClassUtils; /** @@ -45,13 +45,13 @@ import org.springframework.util.ClassUtils; */ public class EntityRowMapper implements BiFunction { - private final JdbcPersistentEntity entity; + private final RelationalPersistentEntity entity; private final EntityInstantiators entityInstantiators; private final ConversionService conversions; - private final MappingContext, JdbcPersistentProperty> context; + private final MappingContext, RelationalPersistentProperty> context; - public EntityRowMapper(JdbcPersistentEntity entity, EntityInstantiators entityInstantiators, - JdbcMappingContext context) { + public EntityRowMapper(RelationalPersistentEntity entity, EntityInstantiators entityInstantiators, + RelationalMappingContext context) { this.entity = entity; this.entityInstantiators = entityInstantiators; @@ -67,7 +67,7 @@ public class EntityRowMapper implements BiFunction { ConvertingPropertyAccessor propertyAccessor = new ConvertingPropertyAccessor(entity.getPropertyAccessor(result), conversions); - for (JdbcPersistentProperty property : entity) { + for (RelationalPersistentProperty property : entity) { if (entity.isConstructorArgument(property)) { continue; @@ -90,11 +90,12 @@ public class EntityRowMapper implements BiFunction { * Read a single value or a complete Entity from the {@link ResultSet} passed as an argument. * * @param row the {@link Row} to extract the value from. Must not be {@literal null}. - * @param property the {@link JdbcPersistentProperty} for which the value is intended. Must not be {@literal null}. + * @param property the {@link RelationalPersistentProperty} for which the value is intended. Must not be + * {@literal null}. * @param prefix to be used for all column names accessed by this method. Must not be {@literal null}. * @return the value read from the {@link ResultSet}. May be {@literal null}. */ - private Object readFrom(Row row, JdbcPersistentProperty property, String prefix) { + private Object readFrom(Row row, RelationalPersistentProperty property, String prefix) { try { @@ -109,7 +110,7 @@ public class EntityRowMapper implements BiFunction { } } - private static Class getType(JdbcPersistentProperty property) { + private static Class getType(RelationalPersistentProperty property) { return ClassUtils.resolvePrimitiveIfNecessary(property.getActualType()); } @@ -118,7 +119,7 @@ public class EntityRowMapper implements BiFunction { String prefix = property.getName() + "_"; @SuppressWarnings("unchecked") - JdbcPersistentEntity entity = (JdbcPersistentEntity) context + RelationalPersistentEntity entity = (RelationalPersistentEntity) context .getRequiredPersistentEntity(property.getActualType()); if (readFrom(row, entity.getRequiredIdProperty(), prefix) == null) { @@ -130,7 +131,7 @@ public class EntityRowMapper implements BiFunction { PersistentPropertyAccessor accessor = entity.getPropertyAccessor(instance); ConvertingPropertyAccessor propertyAccessor = new ConvertingPropertyAccessor(accessor, conversions); - for (JdbcPersistentProperty p : entity) { + for (RelationalPersistentProperty p : entity) { if (!entity.isConstructorArgument(property)) { propertyAccessor.setProperty(p, readFrom(row, p, prefix)); } @@ -139,17 +140,17 @@ public class EntityRowMapper implements BiFunction { return instance; } - private S createInstance(Row row, String prefix, JdbcPersistentEntity entity) { + private S createInstance(Row row, String prefix, RelationalPersistentEntity entity) { return entityInstantiators.getInstantiatorFor(entity).createInstance(entity, new RowParameterValueProvider(row, entity, conversions, prefix)); } @RequiredArgsConstructor - private static class RowParameterValueProvider implements ParameterValueProvider { + private static class RowParameterValueProvider implements ParameterValueProvider { private final @NonNull Row resultSet; - private final @NonNull JdbcPersistentEntity entity; + private final @NonNull RelationalPersistentEntity entity; private final @NonNull ConversionService conversionService; private final @NonNull String prefix; @@ -158,7 +159,7 @@ public class EntityRowMapper implements BiFunction { * @see org.springframework.data.mapping.model.ParameterValueProvider#getParameterValue(org.springframework.data.mapping.PreferredConstructor.Parameter) */ @Override - public T getParameterValue(Parameter parameter) { + public T getParameterValue(Parameter parameter) { String column = prefix + entity.getRequiredPersistentProperty(parameter.getName()).getColumnName(); diff --git a/src/main/java/org/springframework/data/r2dbc/function/convert/MappingR2dbcConverter.java b/src/main/java/org/springframework/data/r2dbc/function/convert/MappingR2dbcConverter.java index fae18435c..6f712d0ec 100644 --- a/src/main/java/org/springframework/data/r2dbc/function/convert/MappingR2dbcConverter.java +++ b/src/main/java/org/springframework/data/r2dbc/function/convert/MappingR2dbcConverter.java @@ -23,10 +23,10 @@ import java.util.Map; import java.util.Optional; import java.util.function.BiFunction; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentProperty; import org.springframework.data.mapping.PersistentPropertyAccessor; import org.springframework.data.mapping.context.MappingContext; +import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; +import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -37,10 +37,10 @@ import org.springframework.util.ClassUtils; */ public class MappingR2dbcConverter { - private final MappingContext, JdbcPersistentProperty> mappingContext; + private final MappingContext, RelationalPersistentProperty> mappingContext; public MappingR2dbcConverter( - MappingContext, JdbcPersistentProperty> mappingContext) { + MappingContext, RelationalPersistentProperty> mappingContext) { this.mappingContext = mappingContext; } @@ -56,13 +56,13 @@ public class MappingR2dbcConverter { Assert.notNull(object, "Entity object must not be null!"); Class userClass = ClassUtils.getUserClass(object); - JdbcPersistentEntity entity = mappingContext.getRequiredPersistentEntity(userClass); + RelationalPersistentEntity entity = mappingContext.getRequiredPersistentEntity(userClass); Map> update = new LinkedHashMap<>(); PersistentPropertyAccessor propertyAccessor = entity.getPropertyAccessor(object); - for (JdbcPersistentProperty property : entity) { + for (RelationalPersistentProperty property : entity) { update.put(property.getColumnName(), Optional.ofNullable(propertyAccessor.getProperty(property))); } @@ -82,12 +82,12 @@ public class MappingR2dbcConverter { Assert.notNull(object, "Entity object must not be null!"); Class userClass = ClassUtils.getUserClass(object); - JdbcPersistentEntity entity = mappingContext.getRequiredPersistentEntity(userClass); + RelationalPersistentEntity entity = mappingContext.getRequiredPersistentEntity(userClass); return (row, metadata) -> { PersistentPropertyAccessor propertyAccessor = entity.getPropertyAccessor(object); - JdbcPersistentProperty idProperty = entity.getRequiredIdProperty(); + RelationalPersistentProperty idProperty = entity.getRequiredIdProperty(); if (propertyAccessor.getProperty(idProperty) == null) { @@ -99,7 +99,7 @@ public class MappingR2dbcConverter { }; } - public MappingContext, JdbcPersistentProperty> getMappingContext() { + public MappingContext, RelationalPersistentProperty> getMappingContext() { return mappingContext; } } diff --git a/src/main/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryExecution.java b/src/main/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryExecution.java index 6c846effa..f0f45e90c 100644 --- a/src/main/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryExecution.java +++ b/src/main/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryExecution.java @@ -20,10 +20,10 @@ import lombok.RequiredArgsConstructor; import org.springframework.core.convert.converter.Converter; import org.springframework.data.convert.EntityInstantiators; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentProperty; import org.springframework.data.mapping.context.MappingContext; import org.springframework.data.r2dbc.function.FetchSpec; +import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; +import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; import org.springframework.data.relational.repository.query.DtoInstantiatingConverter; import org.springframework.data.repository.query.ResultProcessor; import org.springframework.data.repository.query.ReturnedType; @@ -64,7 +64,7 @@ interface R2dbcQueryExecution { final class ResultProcessingConverter implements Converter { private final @NonNull ResultProcessor processor; - private final @NonNull MappingContext, JdbcPersistentProperty> mappingContext; + private final @NonNull MappingContext, RelationalPersistentProperty> mappingContext; private final @NonNull EntityInstantiators instantiators; /* (non-Javadoc) diff --git a/src/main/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryMethod.java b/src/main/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryMethod.java index 55249bca7..3ebf20148 100644 --- a/src/main/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryMethod.java +++ b/src/main/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryMethod.java @@ -26,11 +26,11 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import org.springframework.data.domain.Sort; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentProperty; import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.mapping.context.MappingContext; import org.springframework.data.projection.ProjectionFactory; +import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; +import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; import org.springframework.data.relational.repository.query.RelationalEntityMetadata; import org.springframework.data.relational.repository.query.RelationalParameters; import org.springframework.data.relational.repository.query.SimpleRelationalEntityMetadata; @@ -56,7 +56,7 @@ public class R2dbcQueryMethod extends QueryMethod { private static final ClassTypeInformation SLICE_TYPE = ClassTypeInformation.from(Slice.class); private final Method method; - private final MappingContext, JdbcPersistentProperty> mappingContext; + private final MappingContext, RelationalPersistentProperty> mappingContext; private final Optional query; private @Nullable RelationalEntityMetadata metadata; @@ -70,7 +70,7 @@ public class R2dbcQueryMethod extends QueryMethod { * @param mappingContext must not be {@literal null}. */ public R2dbcQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory projectionFactory, - MappingContext, JdbcPersistentProperty> mappingContext) { + MappingContext, RelationalPersistentProperty> mappingContext) { super(method, metadata, projectionFactory); @@ -162,11 +162,11 @@ public class R2dbcQueryMethod extends QueryMethod { } else { - JdbcPersistentEntity returnedEntity = mappingContext.getPersistentEntity(returnedObjectType); - JdbcPersistentEntity managedEntity = mappingContext.getRequiredPersistentEntity(domainClass); + RelationalPersistentEntity returnedEntity = mappingContext.getPersistentEntity(returnedObjectType); + RelationalPersistentEntity managedEntity = mappingContext.getRequiredPersistentEntity(domainClass); returnedEntity = returnedEntity == null || returnedEntity.getType().isInterface() ? managedEntity : returnedEntity; - JdbcPersistentEntity tableEntity = domainClass.isAssignableFrom(returnedObjectType) ? returnedEntity + RelationalPersistentEntity tableEntity = domainClass.isAssignableFrom(returnedObjectType) ? returnedEntity : managedEntity; this.metadata = new SimpleRelationalEntityMetadata<>((Class) returnedEntity.getType(), tableEntity); diff --git a/src/main/java/org/springframework/data/r2dbc/repository/support/R2dbcRepositoryFactory.java b/src/main/java/org/springframework/data/r2dbc/repository/support/R2dbcRepositoryFactory.java index a4482bec8..35b5fd2a9 100644 --- a/src/main/java/org/springframework/data/r2dbc/repository/support/R2dbcRepositoryFactory.java +++ b/src/main/java/org/springframework/data/r2dbc/repository/support/R2dbcRepositoryFactory.java @@ -21,8 +21,6 @@ import lombok.RequiredArgsConstructor; import java.lang.reflect.Method; import java.util.Optional; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentProperty; import org.springframework.data.mapping.context.MappingContext; import org.springframework.data.projection.ProjectionFactory; import org.springframework.data.r2dbc.function.DatabaseClient; @@ -30,6 +28,8 @@ import org.springframework.data.r2dbc.function.convert.MappingR2dbcConverter; import org.springframework.data.r2dbc.repository.R2dbcRepository; import org.springframework.data.r2dbc.repository.query.R2dbcQueryMethod; import org.springframework.data.r2dbc.repository.query.StringBasedR2dbcQuery; +import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; +import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; import org.springframework.data.relational.repository.query.RelationalEntityInformation; import org.springframework.data.relational.repository.support.MappingRelationalEntityInformation; import org.springframework.data.repository.core.NamedQueries; @@ -54,7 +54,7 @@ public class R2dbcRepositoryFactory extends ReactiveRepositoryFactorySupport { private static final SpelExpressionParser EXPRESSION_PARSER = new SpelExpressionParser(); private final DatabaseClient databaseClient; - private final MappingContext, JdbcPersistentProperty> mappingContext; + private final MappingContext, RelationalPersistentProperty> mappingContext; private final MappingR2dbcConverter converter; /** @@ -64,7 +64,7 @@ public class R2dbcRepositoryFactory extends ReactiveRepositoryFactorySupport { * @param mappingContext must not be {@literal null}. */ public R2dbcRepositoryFactory(DatabaseClient databaseClient, - MappingContext, JdbcPersistentProperty> mappingContext) { + MappingContext, RelationalPersistentProperty> mappingContext) { Assert.notNull(databaseClient, "DatabaseClient must not be null!"); Assert.notNull(mappingContext, "MappingContext must not be null!"); @@ -118,9 +118,9 @@ public class R2dbcRepositoryFactory extends ReactiveRepositoryFactorySupport { private RelationalEntityInformation getEntityInformation(Class domainClass, @Nullable RepositoryInformation information) { - JdbcPersistentEntity entity = mappingContext.getRequiredPersistentEntity(domainClass); + RelationalPersistentEntity entity = mappingContext.getRequiredPersistentEntity(domainClass); - return new MappingRelationalEntityInformation<>((JdbcPersistentEntity) entity); + return new MappingRelationalEntityInformation<>((RelationalPersistentEntity) entity); } /** diff --git a/src/main/java/org/springframework/data/relational/repository/query/DtoInstantiatingConverter.java b/src/main/java/org/springframework/data/relational/repository/query/DtoInstantiatingConverter.java index 0d8f1ebc5..a40eedae0 100644 --- a/src/main/java/org/springframework/data/relational/repository/query/DtoInstantiatingConverter.java +++ b/src/main/java/org/springframework/data/relational/repository/query/DtoInstantiatingConverter.java @@ -18,8 +18,6 @@ package org.springframework.data.relational.repository.query; import org.springframework.core.convert.converter.Converter; import org.springframework.data.convert.EntityInstantiator; import org.springframework.data.convert.EntityInstantiators; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentProperty; import org.springframework.data.mapping.PersistentEntity; import org.springframework.data.mapping.PersistentProperty; import org.springframework.data.mapping.PersistentPropertyAccessor; @@ -28,6 +26,8 @@ import org.springframework.data.mapping.PreferredConstructor.Parameter; import org.springframework.data.mapping.SimplePropertyHandler; import org.springframework.data.mapping.context.MappingContext; import org.springframework.data.mapping.model.ParameterValueProvider; +import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; +import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; import org.springframework.util.Assert; /** @@ -49,7 +49,7 @@ public class DtoInstantiatingConverter implements Converter { * @param instantiators must not be {@literal null}. */ public DtoInstantiatingConverter(Class dtoType, - MappingContext, JdbcPersistentProperty> context, + MappingContext, RelationalPersistentProperty> context, EntityInstantiators instantiator) { Assert.notNull(dtoType, "DTO type must not be null!"); diff --git a/src/main/java/org/springframework/data/relational/repository/query/RelationalEntityMetadata.java b/src/main/java/org/springframework/data/relational/repository/query/RelationalEntityMetadata.java index 92fff24ff..8691cb5a5 100644 --- a/src/main/java/org/springframework/data/relational/repository/query/RelationalEntityMetadata.java +++ b/src/main/java/org/springframework/data/relational/repository/query/RelationalEntityMetadata.java @@ -15,7 +15,7 @@ */ package org.springframework.data.relational.repository.query; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity; +import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; import org.springframework.data.repository.core.EntityMetadata; /** @@ -33,9 +33,9 @@ public interface RelationalEntityMetadata extends EntityMetadata { String getTableName(); /** - * Returns the {@link JdbcPersistentEntity} that supposed to determine the table to be queried. + * Returns the {@link RelationalPersistentEntity} that supposed to determine the table to be queried. * * @return */ - JdbcPersistentEntity getTableEntity(); + RelationalPersistentEntity getTableEntity(); } diff --git a/src/main/java/org/springframework/data/relational/repository/query/SimpleRelationalEntityMetadata.java b/src/main/java/org/springframework/data/relational/repository/query/SimpleRelationalEntityMetadata.java index 9e650912d..f64c7f513 100644 --- a/src/main/java/org/springframework/data/relational/repository/query/SimpleRelationalEntityMetadata.java +++ b/src/main/java/org/springframework/data/relational/repository/query/SimpleRelationalEntityMetadata.java @@ -17,7 +17,7 @@ package org.springframework.data.relational.repository.query; import lombok.Getter; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity; +import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; import org.springframework.util.Assert; /** @@ -28,16 +28,16 @@ import org.springframework.util.Assert; public class SimpleRelationalEntityMetadata implements RelationalEntityMetadata { private final Class type; - private final @Getter JdbcPersistentEntity tableEntity; + private final @Getter RelationalPersistentEntity tableEntity; /** - * Creates a new {@link SimpleRelationalEntityMetadata} using the given type and {@link JdbcPersistentEntity} to use - * for table lookups. + * Creates a new {@link SimpleRelationalEntityMetadata} using the given type and {@link RelationalPersistentEntity} to + * use for table lookups. * * @param type must not be {@literal null}. * @param tableEntity must not be {@literal null}. */ - public SimpleRelationalEntityMetadata(Class type, JdbcPersistentEntity tableEntity) { + public SimpleRelationalEntityMetadata(Class type, RelationalPersistentEntity tableEntity) { Assert.notNull(type, "Type must not be null!"); Assert.notNull(tableEntity, "Table entity must not be null!"); @@ -54,7 +54,7 @@ public class SimpleRelationalEntityMetadata implements RelationalEntityMetada } /* (non-Javadoc) - * @see org.springframework.data.jdbc.repository.query.JdbcEntityMetadata#getTableName() + * @see org.springframework.data.jdbc.repository.query.RelationalEntityMetadata#getTableName() */ public String getTableName() { return tableEntity.getTableName(); diff --git a/src/main/java/org/springframework/data/relational/repository/support/MappingRelationalEntityInformation.java b/src/main/java/org/springframework/data/relational/repository/support/MappingRelationalEntityInformation.java index 3f75d91b5..6231de0d8 100644 --- a/src/main/java/org/springframework/data/relational/repository/support/MappingRelationalEntityInformation.java +++ b/src/main/java/org/springframework/data/relational/repository/support/MappingRelationalEntityInformation.java @@ -15,13 +15,13 @@ */ package org.springframework.data.relational.repository.support; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity; +import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; import org.springframework.data.relational.repository.query.RelationalEntityInformation; import org.springframework.data.repository.core.support.PersistentEntityInformation; import org.springframework.lang.Nullable; /** - * {@link RelationalEntityInformation} implementation using a {@link JdbcPersistentEntity} instance to lookup the + * {@link RelationalEntityInformation} implementation using a {@link RelationalPersistentEntity} instance to lookup the * necessary information. Can be configured with a custom table name. *

* Entity types that do not declare an explicit Id type fall back to {@link Long} as Id type. @@ -31,51 +31,51 @@ import org.springframework.lang.Nullable; public class MappingRelationalEntityInformation extends PersistentEntityInformation implements RelationalEntityInformation { - private final JdbcPersistentEntity entityMetadata; + private final RelationalPersistentEntity entityMetadata; private final @Nullable String customTableName; private final Class fallbackIdType; /** - * Creates a new {@link MappingRelationalEntityInformation} for the given {@link JdbcPersistentEntity}. + * Creates a new {@link MappingRelationalEntityInformation} for the given {@link RelationalPersistentEntity}. * * @param entity must not be {@literal null}. */ - public MappingRelationalEntityInformation(JdbcPersistentEntity entity) { + public MappingRelationalEntityInformation(RelationalPersistentEntity entity) { this(entity, null, null); } /** - * Creates a new {@link MappingRelationalEntityInformation} for the given {@link JdbcPersistentEntity} and fallback - * identifier type. + * Creates a new {@link MappingRelationalEntityInformation} for the given {@link RelationalPersistentEntity} and + * fallback identifier type. * * @param entity must not be {@literal null}. * @param fallbackIdType can be {@literal null}. */ - public MappingRelationalEntityInformation(JdbcPersistentEntity entity, @Nullable Class fallbackIdType) { + public MappingRelationalEntityInformation(RelationalPersistentEntity entity, @Nullable Class fallbackIdType) { this(entity, null, fallbackIdType); } /** - * Creates a new {@link MappingRelationalEntityInformation} for the given {@link JdbcPersistentEntity} and custom - * table name. + * Creates a new {@link MappingRelationalEntityInformation} for the given {@link RelationalPersistentEntity} and + * custom table name. * * @param entity must not be {@literal null}. * @param customTableName can be {@literal null}. */ - public MappingRelationalEntityInformation(JdbcPersistentEntity entity, String customTableName) { + public MappingRelationalEntityInformation(RelationalPersistentEntity entity, String customTableName) { this(entity, customTableName, null); } /** - * Creates a new {@link MappingRelationalEntityInformation} for the given {@link JdbcPersistentEntity}, collection - * name and identifier type. + * Creates a new {@link MappingRelationalEntityInformation} for the given {@link RelationalPersistentEntity}, + * collection name and identifier type. * * @param entity must not be {@literal null}. * @param customTableName can be {@literal null}. * @param idType can be {@literal null}. */ @SuppressWarnings("unchecked") - private MappingRelationalEntityInformation(JdbcPersistentEntity entity, @Nullable String customTableName, + private MappingRelationalEntityInformation(RelationalPersistentEntity entity, @Nullable String customTableName, @Nullable Class idType) { super(entity); diff --git a/src/test/java/org/springframework/data/r2dbc/function/DatabaseClientIntegrationTests.java b/src/test/java/org/springframework/data/r2dbc/function/DatabaseClientIntegrationTests.java index 2ce515495..77cdac617 100644 --- a/src/test/java/org/springframework/data/r2dbc/function/DatabaseClientIntegrationTests.java +++ b/src/test/java/org/springframework/data/r2dbc/function/DatabaseClientIntegrationTests.java @@ -28,8 +28,8 @@ import org.junit.Test; import org.springframework.dao.DuplicateKeyException; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; -import org.springframework.data.jdbc.core.mapping.Table; import org.springframework.data.jdbc.testing.R2dbcIntegrationTestSupport; +import org.springframework.data.relational.core.mapping.Table; import org.springframework.jdbc.core.JdbcTemplate; /** diff --git a/src/test/java/org/springframework/data/r2dbc/repository/R2dbcRepositoryIntegrationTests.java b/src/test/java/org/springframework/data/r2dbc/repository/R2dbcRepositoryIntegrationTests.java index d18fdc5cb..5a6679cdc 100644 --- a/src/test/java/org/springframework/data/r2dbc/repository/R2dbcRepositoryIntegrationTests.java +++ b/src/test/java/org/springframework/data/r2dbc/repository/R2dbcRepositoryIntegrationTests.java @@ -32,13 +32,13 @@ import org.junit.Before; import org.junit.Test; import org.springframework.data.annotation.Id; import org.springframework.data.convert.EntityInstantiators; -import org.springframework.data.jdbc.core.mapping.JdbcMappingContext; -import org.springframework.data.jdbc.core.mapping.Table; import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.jdbc.testing.R2dbcIntegrationTestSupport; import org.springframework.data.r2dbc.function.DatabaseClient; import org.springframework.data.r2dbc.function.DefaultReactiveDataAccessStrategy; import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory; +import org.springframework.data.relational.core.mapping.RelationalMappingContext; +import org.springframework.data.relational.core.mapping.Table; import org.springframework.data.repository.reactive.ReactiveCrudRepository; import org.springframework.jdbc.core.JdbcTemplate; @@ -49,7 +49,7 @@ import org.springframework.jdbc.core.JdbcTemplate; */ public class R2dbcRepositoryIntegrationTests extends R2dbcIntegrationTestSupport { - private static JdbcMappingContext mappingContext = new JdbcMappingContext(); + private static RelationalMappingContext mappingContext = new RelationalMappingContext(); private ConnectionFactory connectionFactory; private DatabaseClient databaseClient; diff --git a/src/test/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryMethodUnitTests.java b/src/test/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryMethodUnitTests.java index 1dcb41cdf..415fcc2dc 100644 --- a/src/test/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryMethodUnitTests.java +++ b/src/test/java/org/springframework/data/r2dbc/repository/query/R2dbcQueryMethodUnitTests.java @@ -28,9 +28,9 @@ import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import org.springframework.data.jdbc.core.mapping.JdbcMappingContext; import org.springframework.data.projection.ProjectionFactory; import org.springframework.data.projection.SpelAwareProxyProjectionFactory; +import org.springframework.data.relational.core.mapping.RelationalMappingContext; import org.springframework.data.relational.repository.query.RelationalEntityMetadata; import org.springframework.data.repository.Repository; import org.springframework.data.repository.core.support.DefaultRepositoryMetadata; @@ -42,11 +42,11 @@ import org.springframework.data.repository.core.support.DefaultRepositoryMetadat */ public class R2dbcQueryMethodUnitTests { - JdbcMappingContext context; + RelationalMappingContext context; @Before public void setUp() { - context = new JdbcMappingContext(); + this.context = new RelationalMappingContext(); } @Test diff --git a/src/test/java/org/springframework/data/r2dbc/repository/query/StringBasedR2dbcQueryUnitTests.java b/src/test/java/org/springframework/data/r2dbc/repository/query/StringBasedR2dbcQueryUnitTests.java index 9ddbbe1ca..afcebfa92 100644 --- a/src/test/java/org/springframework/data/r2dbc/repository/query/StringBasedR2dbcQueryUnitTests.java +++ b/src/test/java/org/springframework/data/r2dbc/repository/query/StringBasedR2dbcQueryUnitTests.java @@ -16,6 +16,7 @@ package org.springframework.data.r2dbc.repository.query; import static org.assertj.core.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; import java.lang.reflect.Method; @@ -25,13 +26,13 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.springframework.data.jdbc.core.mapping.JdbcMappingContext; import org.springframework.data.jdbc.repository.query.Query; import org.springframework.data.projection.ProjectionFactory; import org.springframework.data.projection.SpelAwareProxyProjectionFactory; import org.springframework.data.r2dbc.function.DatabaseClient; import org.springframework.data.r2dbc.function.DatabaseClient.GenericExecuteSpec; import org.springframework.data.r2dbc.function.convert.MappingR2dbcConverter; +import org.springframework.data.relational.core.mapping.RelationalMappingContext; import org.springframework.data.repository.Repository; import org.springframework.data.repository.core.RepositoryMetadata; import org.springframework.data.repository.core.support.AbstractRepositoryMetadata; @@ -52,7 +53,7 @@ public class StringBasedR2dbcQueryUnitTests { @Mock private DatabaseClient databaseClient; @Mock private GenericExecuteSpec bindSpec; - private JdbcMappingContext mappingContext; + private RelationalMappingContext mappingContext; private MappingR2dbcConverter converter; private ProjectionFactory factory; private RepositoryMetadata metadata; @@ -61,7 +62,7 @@ public class StringBasedR2dbcQueryUnitTests { @SuppressWarnings("unchecked") public void setUp() { - this.mappingContext = new JdbcMappingContext(); + this.mappingContext = new RelationalMappingContext(); this.converter = new MappingR2dbcConverter(this.mappingContext); this.metadata = AbstractRepositoryMetadata.getMetadata(SampleRepository.class); this.factory = new SpelAwareProxyProjectionFactory(); diff --git a/src/test/java/org/springframework/data/r2dbc/repository/support/R2dbcRepositoryFactoryUnitTests.java b/src/test/java/org/springframework/data/r2dbc/repository/support/R2dbcRepositoryFactoryUnitTests.java index 5448c9772..30f91bbe5 100644 --- a/src/test/java/org/springframework/data/r2dbc/repository/support/R2dbcRepositoryFactoryUnitTests.java +++ b/src/test/java/org/springframework/data/r2dbc/repository/support/R2dbcRepositoryFactoryUnitTests.java @@ -23,9 +23,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity; import org.springframework.data.mapping.context.MappingContext; import org.springframework.data.r2dbc.function.DatabaseClient; +import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; import org.springframework.data.relational.repository.query.RelationalEntityInformation; import org.springframework.data.relational.repository.support.MappingRelationalEntityInformation; import org.springframework.data.repository.Repository; @@ -40,7 +40,7 @@ public class R2dbcRepositoryFactoryUnitTests { @Mock DatabaseClient databaseClient; @Mock @SuppressWarnings("rawtypes") MappingContext mappingContext; - @Mock @SuppressWarnings("rawtypes") JdbcPersistentEntity entity; + @Mock @SuppressWarnings("rawtypes") RelationalPersistentEntity entity; @Before @SuppressWarnings("unchecked") @@ -50,7 +50,7 @@ public class R2dbcRepositoryFactoryUnitTests { @Test @SuppressWarnings("unchecked") - public void usesMappingJdbcEntityInformationIfMappingContextSet() { + public void usesMappingRelationalEntityInformationIfMappingContextSet() { R2dbcRepositoryFactory factory = new R2dbcRepositoryFactory(databaseClient, mappingContext); RelationalEntityInformation entityInformation = factory.getEntityInformation(Person.class); diff --git a/src/test/java/org/springframework/data/r2dbc/repository/support/SimpleR2dbcRepositoryIntegrationTests.java b/src/test/java/org/springframework/data/r2dbc/repository/support/SimpleR2dbcRepositoryIntegrationTests.java index 6a42ce25a..8d9b49d71 100644 --- a/src/test/java/org/springframework/data/r2dbc/repository/support/SimpleR2dbcRepositoryIntegrationTests.java +++ b/src/test/java/org/springframework/data/r2dbc/repository/support/SimpleR2dbcRepositoryIntegrationTests.java @@ -34,13 +34,13 @@ import org.junit.Before; import org.junit.Test; import org.springframework.data.annotation.Id; import org.springframework.data.convert.EntityInstantiators; -import org.springframework.data.jdbc.core.mapping.JdbcMappingContext; -import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity; -import org.springframework.data.jdbc.core.mapping.Table; import org.springframework.data.jdbc.testing.R2dbcIntegrationTestSupport; import org.springframework.data.r2dbc.function.DatabaseClient; import org.springframework.data.r2dbc.function.DefaultReactiveDataAccessStrategy; import org.springframework.data.r2dbc.function.convert.MappingR2dbcConverter; +import org.springframework.data.relational.core.mapping.RelationalMappingContext; +import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; +import org.springframework.data.relational.core.mapping.Table; import org.springframework.data.relational.repository.query.RelationalEntityInformation; import org.springframework.data.relational.repository.support.MappingRelationalEntityInformation; import org.springframework.jdbc.core.JdbcTemplate; @@ -52,7 +52,7 @@ import org.springframework.jdbc.core.JdbcTemplate; */ public class SimpleR2dbcRepositoryIntegrationTests extends R2dbcIntegrationTestSupport { - private static JdbcMappingContext mappingContext = new JdbcMappingContext(); + private static RelationalMappingContext mappingContext = new RelationalMappingContext(); private ConnectionFactory connectionFactory; private DatabaseClient databaseClient; @@ -69,7 +69,7 @@ public class SimpleR2dbcRepositoryIntegrationTests extends R2dbcIntegrationTestS .dataAccessStrategy(new DefaultReactiveDataAccessStrategy(mappingContext, new EntityInstantiators())).build(); RelationalEntityInformation entityInformation = new MappingRelationalEntityInformation<>( - (JdbcPersistentEntity) mappingContext.getRequiredPersistentEntity(LegoSet.class)); + (RelationalPersistentEntity) mappingContext.getRequiredPersistentEntity(LegoSet.class)); this.repository = new SimpleR2dbcRepository<>(entityInformation, databaseClient, new MappingR2dbcConverter(mappingContext)); @@ -93,8 +93,7 @@ public class SimpleR2dbcRepositoryIntegrationTests extends R2dbcIntegrationTestS .consumeNextWith(actual -> { assertThat(actual.getId()).isNotNull(); - }) - .verifyComplete(); + }).verifyComplete(); Map map = jdbc.queryForMap("SELECT * FROM repo_legoset"); assertThat(map).containsEntry("name", "SCHAUFELRADBAGGER").containsEntry("manual", 12).containsKey("id");