#2 - Adapt code to API changes.

This commit is contained in:
Oliver Gierke
2018-06-22 15:58:28 +02:00
committed by Mark Paluch
parent bea95010ae
commit 853b3fb449
16 changed files with 102 additions and 101 deletions

View File

@@ -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<String> 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<Pair<String, Object>> 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 <T> BiFunction<Row, RowMetadata, T> getRowMapper(Class<T> typeToRead) {
return new EntityRowMapper<T>((JdbcPersistentEntity) mappingContext.getRequiredPersistentEntity(typeToRead),
return new EntityRowMapper<T>((RelationalPersistentEntity) mappingContext.getRequiredPersistentEntity(typeToRead),
instantiators, mappingContext);
}

View File

@@ -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<T> implements BiFunction<Row, RowMetadata, T> {
private final JdbcPersistentEntity<T> entity;
private final RelationalPersistentEntity<T> entity;
private final EntityInstantiators entityInstantiators;
private final ConversionService conversions;
private final MappingContext<JdbcPersistentEntity<?>, JdbcPersistentProperty> context;
private final MappingContext<RelationalPersistentEntity<?>, RelationalPersistentProperty> context;
public EntityRowMapper(JdbcPersistentEntity<T> entity, EntityInstantiators entityInstantiators,
JdbcMappingContext context) {
public EntityRowMapper(RelationalPersistentEntity<T> entity, EntityInstantiators entityInstantiators,
RelationalMappingContext context) {
this.entity = entity;
this.entityInstantiators = entityInstantiators;
@@ -67,7 +67,7 @@ public class EntityRowMapper<T> implements BiFunction<Row, RowMetadata, T> {
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<T> implements BiFunction<Row, RowMetadata, T> {
* 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<T> implements BiFunction<Row, RowMetadata, T> {
}
}
private static Class<?> getType(JdbcPersistentProperty property) {
private static Class<?> getType(RelationalPersistentProperty property) {
return ClassUtils.resolvePrimitiveIfNecessary(property.getActualType());
}
@@ -118,7 +119,7 @@ public class EntityRowMapper<T> implements BiFunction<Row, RowMetadata, T> {
String prefix = property.getName() + "_";
@SuppressWarnings("unchecked")
JdbcPersistentEntity<S> entity = (JdbcPersistentEntity<S>) context
RelationalPersistentEntity<S> entity = (RelationalPersistentEntity<S>) context
.getRequiredPersistentEntity(property.getActualType());
if (readFrom(row, entity.getRequiredIdProperty(), prefix) == null) {
@@ -130,7 +131,7 @@ public class EntityRowMapper<T> implements BiFunction<Row, RowMetadata, T> {
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<T> implements BiFunction<Row, RowMetadata, T> {
return instance;
}
private <S> S createInstance(Row row, String prefix, JdbcPersistentEntity<S> entity) {
private <S> S createInstance(Row row, String prefix, RelationalPersistentEntity<S> entity) {
return entityInstantiators.getInstantiatorFor(entity).createInstance(entity,
new RowParameterValueProvider(row, entity, conversions, prefix));
}
@RequiredArgsConstructor
private static class RowParameterValueProvider implements ParameterValueProvider<JdbcPersistentProperty> {
private static class RowParameterValueProvider implements ParameterValueProvider<RelationalPersistentProperty> {
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<T> implements BiFunction<Row, RowMetadata, T> {
* @see org.springframework.data.mapping.model.ParameterValueProvider#getParameterValue(org.springframework.data.mapping.PreferredConstructor.Parameter)
*/
@Override
public <T> T getParameterValue(Parameter<T, JdbcPersistentProperty> parameter) {
public <T> T getParameterValue(Parameter<T, RelationalPersistentProperty> parameter) {
String column = prefix + entity.getRequiredPersistentProperty(parameter.getName()).getColumnName();

View File

@@ -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<? extends JdbcPersistentEntity<?>, JdbcPersistentProperty> mappingContext;
private final MappingContext<? extends RelationalPersistentEntity<?>, RelationalPersistentProperty> mappingContext;
public MappingR2dbcConverter(
MappingContext<? extends JdbcPersistentEntity<?>, JdbcPersistentProperty> mappingContext) {
MappingContext<? extends RelationalPersistentEntity<?>, 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<String, Optional<Object>> 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<? extends JdbcPersistentEntity<?>, JdbcPersistentProperty> getMappingContext() {
public MappingContext<? extends RelationalPersistentEntity<?>, RelationalPersistentProperty> getMappingContext() {
return mappingContext;
}
}

View File

@@ -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<Object, Object> {
private final @NonNull ResultProcessor processor;
private final @NonNull MappingContext<? extends JdbcPersistentEntity<?>, JdbcPersistentProperty> mappingContext;
private final @NonNull MappingContext<? extends RelationalPersistentEntity<?>, RelationalPersistentProperty> mappingContext;
private final @NonNull EntityInstantiators instantiators;
/* (non-Javadoc)

View File

@@ -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> SLICE_TYPE = ClassTypeInformation.from(Slice.class);
private final Method method;
private final MappingContext<? extends JdbcPersistentEntity<?>, JdbcPersistentProperty> mappingContext;
private final MappingContext<? extends RelationalPersistentEntity<?>, RelationalPersistentProperty> mappingContext;
private final Optional<Query> 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<? extends JdbcPersistentEntity<?>, JdbcPersistentProperty> mappingContext) {
MappingContext<? extends RelationalPersistentEntity<?>, 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<Object>) returnedEntity.getType(), tableEntity);

View File

@@ -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<? extends JdbcPersistentEntity<?>, JdbcPersistentProperty> mappingContext;
private final MappingContext<? extends RelationalPersistentEntity<?>, 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<? extends JdbcPersistentEntity<?>, JdbcPersistentProperty> mappingContext) {
MappingContext<? extends RelationalPersistentEntity<?>, 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 <T, ID> RelationalEntityInformation<T, ID> getEntityInformation(Class<T> domainClass,
@Nullable RepositoryInformation information) {
JdbcPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(domainClass);
RelationalPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(domainClass);
return new MappingRelationalEntityInformation<>((JdbcPersistentEntity<T>) entity);
return new MappingRelationalEntityInformation<>((RelationalPersistentEntity<T>) entity);
}
/**

View File

@@ -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<Object, Object> {
* @param instantiators must not be {@literal null}.
*/
public DtoInstantiatingConverter(Class<?> dtoType,
MappingContext<? extends JdbcPersistentEntity<?>, JdbcPersistentProperty> context,
MappingContext<? extends RelationalPersistentEntity<?>, RelationalPersistentProperty> context,
EntityInstantiators instantiator) {
Assert.notNull(dtoType, "DTO type must not be null!");

View File

@@ -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<T> extends EntityMetadata<T> {
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();
}

View File

@@ -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<T> implements RelationalEntityMetadata<T> {
private final Class<T> 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<T> type, JdbcPersistentEntity<?> tableEntity) {
public SimpleRelationalEntityMetadata(Class<T> 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<T> 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();

View File

@@ -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.
* <p>
* 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<T, ID> extends PersistentEntityInformation<T, ID>
implements RelationalEntityInformation<T, ID> {
private final JdbcPersistentEntity<T> entityMetadata;
private final RelationalPersistentEntity<T> entityMetadata;
private final @Nullable String customTableName;
private final Class<ID> 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<T> entity) {
public MappingRelationalEntityInformation(RelationalPersistentEntity<T> 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<T> entity, @Nullable Class<ID> fallbackIdType) {
public MappingRelationalEntityInformation(RelationalPersistentEntity<T> entity, @Nullable Class<ID> 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<T> entity, String customTableName) {
public MappingRelationalEntityInformation(RelationalPersistentEntity<T> 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<T> entity, @Nullable String customTableName,
private MappingRelationalEntityInformation(RelationalPersistentEntity<T> entity, @Nullable String customTableName,
@Nullable Class<ID> idType) {
super(entity);