DATAJDBC-226 - Renamed all types named Jdbc… in relational package Relational….
This commit is contained in:
@@ -22,7 +22,7 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.data.mapping.PropertyPath;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentProperty;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
|
||||
|
||||
/**
|
||||
* Delegates each methods to the {@link DataAccessStrategy}s passed to the constructor in turn until the first that does
|
||||
@@ -90,7 +90,7 @@ public class CascadingDataAccessStrategy implements DataAccessStrategy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Iterable<T> findAllByProperty(Object rootId, JdbcPersistentProperty property) {
|
||||
public <T> Iterable<T> findAllByProperty(Object rootId, RelationalPersistentProperty property) {
|
||||
return collect(das -> das.findAllByProperty(rootId, property));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.data.jdbc.core;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.mapping.PropertyPath;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentProperty;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
@@ -129,7 +129,7 @@ public interface DataAccessStrategy {
|
||||
* @param rootId Id of the root object on which the {@literal propertyPath} is based.
|
||||
* @param property Leading from the root object to the entities to be found.
|
||||
*/
|
||||
<T> Iterable<T> findAllByProperty(Object rootId, JdbcPersistentProperty property);
|
||||
<T> Iterable<T> findAllByProperty(Object rootId, RelationalPersistentProperty property);
|
||||
|
||||
/**
|
||||
* returns if a row with the given id exists for the given type.
|
||||
|
||||
@@ -33,9 +33,9 @@ import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
import org.springframework.data.mapping.PropertyHandler;
|
||||
import org.springframework.data.mapping.PropertyPath;
|
||||
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentEntity;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentProperty;
|
||||
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.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
@@ -58,7 +58,7 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
+ "JDBC driver returns it.";
|
||||
|
||||
private final @NonNull SqlGeneratorSource sqlGeneratorSource;
|
||||
private final @NonNull JdbcMappingContext context;
|
||||
private final @NonNull RelationalMappingContext context;
|
||||
private final @NonNull NamedParameterJdbcOperations operations;
|
||||
private final @NonNull EntityInstantiators instantiators;
|
||||
private final @NonNull DataAccessStrategy accessStrategy;
|
||||
@@ -67,7 +67,7 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
* Creates a {@link DefaultDataAccessStrategy} which references it self for resolution of recursive data accesses.
|
||||
* Only suitable if this is the only access strategy in use.
|
||||
*/
|
||||
public DefaultDataAccessStrategy(SqlGeneratorSource sqlGeneratorSource, JdbcMappingContext context,
|
||||
public DefaultDataAccessStrategy(SqlGeneratorSource sqlGeneratorSource, RelationalMappingContext context,
|
||||
NamedParameterJdbcOperations operations, EntityInstantiators instantiators) {
|
||||
|
||||
this.sqlGeneratorSource = sqlGeneratorSource;
|
||||
@@ -81,12 +81,12 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
public <T> void insert(T instance, Class<T> domainType, Map<String, Object> additionalParameters) {
|
||||
|
||||
KeyHolder holder = new GeneratedKeyHolder();
|
||||
JdbcPersistentEntity<T> persistentEntity = getRequiredPersistentEntity(domainType);
|
||||
RelationalPersistentEntity<T> persistentEntity = getRequiredPersistentEntity(domainType);
|
||||
|
||||
MapSqlParameterSource parameterSource = getPropertyMap(instance, persistentEntity);
|
||||
|
||||
Object idValue = getIdValueOrNull(instance, persistentEntity);
|
||||
JdbcPersistentProperty idProperty = persistentEntity.getIdProperty();
|
||||
RelationalPersistentProperty idProperty = persistentEntity.getIdProperty();
|
||||
|
||||
if (idValue != null) {
|
||||
|
||||
@@ -120,7 +120,7 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
@Override
|
||||
public <S> void update(S instance, Class<S> domainType) {
|
||||
|
||||
JdbcPersistentEntity<S> persistentEntity = getRequiredPersistentEntity(domainType);
|
||||
RelationalPersistentEntity<S> persistentEntity = getRequiredPersistentEntity(domainType);
|
||||
|
||||
operations.update(sql(domainType).getUpdate(), getPropertyMap(instance, persistentEntity));
|
||||
}
|
||||
@@ -145,9 +145,9 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
@Override
|
||||
public void delete(Object rootId, PropertyPath propertyPath) {
|
||||
|
||||
JdbcPersistentEntity<?> rootEntity = context.getRequiredPersistentEntity(propertyPath.getOwningType());
|
||||
RelationalPersistentEntity<?> rootEntity = context.getRequiredPersistentEntity(propertyPath.getOwningType());
|
||||
|
||||
JdbcPersistentProperty referencingProperty = rootEntity.getRequiredPersistentProperty(propertyPath.getSegment());
|
||||
RelationalPersistentProperty referencingProperty = rootEntity.getRequiredPersistentProperty(propertyPath.getSegment());
|
||||
Assert.notNull(referencingProperty, "No property found matching the PropertyPath " + propertyPath);
|
||||
|
||||
String format = sql(rootEntity.getType()).createDeleteByPath(propertyPath);
|
||||
@@ -244,7 +244,7 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> Iterable<T> findAllByProperty(Object rootId, JdbcPersistentProperty property) {
|
||||
public <T> Iterable<T> findAllByProperty(Object rootId, RelationalPersistentProperty property) {
|
||||
|
||||
Assert.notNull(rootId, "rootId must not be null.");
|
||||
|
||||
@@ -277,11 +277,11 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
return result;
|
||||
}
|
||||
|
||||
private <S> MapSqlParameterSource getPropertyMap(final S instance, JdbcPersistentEntity<S> persistentEntity) {
|
||||
private <S> MapSqlParameterSource getPropertyMap(final S instance, RelationalPersistentEntity<S> persistentEntity) {
|
||||
|
||||
MapSqlParameterSource parameters = new MapSqlParameterSource();
|
||||
|
||||
persistentEntity.doWithProperties((PropertyHandler<JdbcPersistentProperty>) property -> {
|
||||
persistentEntity.doWithProperties((PropertyHandler<RelationalPersistentProperty>) property -> {
|
||||
if (!property.isEntity()) {
|
||||
Object value = persistentEntity.getPropertyAccessor(instance).getProperty(property);
|
||||
|
||||
@@ -295,7 +295,7 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
private <S, ID> ID getIdValueOrNull(S instance, JdbcPersistentEntity<S> persistentEntity) {
|
||||
private <S, ID> ID getIdValueOrNull(S instance, RelationalPersistentEntity<S> persistentEntity) {
|
||||
|
||||
ID idValue = (ID) persistentEntity.getIdentifierAccessor(instance).getIdentifier();
|
||||
|
||||
@@ -303,16 +303,16 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
}
|
||||
|
||||
private static <S, ID> boolean isIdPropertyNullOrScalarZero(@Nullable ID idValue,
|
||||
JdbcPersistentEntity<S> persistentEntity) {
|
||||
RelationalPersistentEntity<S> persistentEntity) {
|
||||
|
||||
JdbcPersistentProperty idProperty = persistentEntity.getIdProperty();
|
||||
RelationalPersistentProperty idProperty = persistentEntity.getIdProperty();
|
||||
return idValue == null //
|
||||
|| idProperty == null //
|
||||
|| (idProperty.getType() == int.class && idValue.equals(0)) //
|
||||
|| (idProperty.getType() == long.class && idValue.equals(0L));
|
||||
}
|
||||
|
||||
private <S> void setIdFromJdbc(S instance, KeyHolder holder, JdbcPersistentEntity<S> persistentEntity) {
|
||||
private <S> void setIdFromJdbc(S instance, KeyHolder holder, RelationalPersistentEntity<S> persistentEntity) {
|
||||
|
||||
try {
|
||||
|
||||
@@ -321,7 +321,7 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
PersistentPropertyAccessor accessor = persistentEntity.getPropertyAccessor(instance);
|
||||
ConvertingPropertyAccessor convertingPropertyAccessor = new ConvertingPropertyAccessor(accessor,
|
||||
context.getConversions());
|
||||
JdbcPersistentProperty idProperty = persistentEntity.getRequiredIdProperty();
|
||||
RelationalPersistentProperty idProperty = persistentEntity.getRequiredIdProperty();
|
||||
|
||||
convertingPropertyAccessor.setProperty(idProperty, it);
|
||||
});
|
||||
@@ -331,7 +331,7 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
private <S> Optional<Object> getIdFromHolder(KeyHolder holder, JdbcPersistentEntity<S> persistentEntity) {
|
||||
private <S> Optional<Object> getIdFromHolder(KeyHolder holder, RelationalPersistentEntity<S> persistentEntity) {
|
||||
|
||||
try {
|
||||
// MySQL just returns one value with a special name
|
||||
@@ -348,7 +348,7 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private RowMapper<?> getMapEntityRowMapper(JdbcPersistentProperty property) {
|
||||
private RowMapper<?> getMapEntityRowMapper(RelationalPersistentProperty property) {
|
||||
|
||||
String keyColumn = property.getKeyColumn();
|
||||
|
||||
@@ -364,8 +364,8 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <S> JdbcPersistentEntity<S> getRequiredPersistentEntity(Class<S> domainType) {
|
||||
return (JdbcPersistentEntity<S>) context.getRequiredPersistentEntity(domainType);
|
||||
private <S> RelationalPersistentEntity<S> getRequiredPersistentEntity(Class<S> domainType) {
|
||||
return (RelationalPersistentEntity<S>) context.getRequiredPersistentEntity(domainType);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -375,7 +375,7 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
return null;
|
||||
}
|
||||
|
||||
JdbcPersistentEntity<?> persistentEntity = context.getPersistentEntity(from.getClass());
|
||||
RelationalPersistentEntity<?> persistentEntity = context.getPersistentEntity(from.getClass());
|
||||
|
||||
Object id = persistentEntity == null ? null : persistentEntity.getIdentifierAccessor(from).getIdentifier();
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ import org.springframework.data.relational.core.conversion.DbAction.Delete;
|
||||
import org.springframework.data.relational.core.conversion.DbAction.DeleteAll;
|
||||
import org.springframework.data.relational.core.conversion.DbAction.Insert;
|
||||
import org.springframework.data.relational.core.conversion.DbAction.Update;
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentEntity;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -39,10 +39,10 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
class DefaultJdbcInterpreter implements Interpreter {
|
||||
|
||||
private final JdbcMappingContext context;
|
||||
private final RelationalMappingContext context;
|
||||
private final DataAccessStrategy accessStrategy;
|
||||
|
||||
DefaultJdbcInterpreter(JdbcMappingContext context, DataAccessStrategy accessStrategy) {
|
||||
DefaultJdbcInterpreter(RelationalMappingContext context, DataAccessStrategy accessStrategy) {
|
||||
|
||||
this.context = context;
|
||||
this.accessStrategy = accessStrategy;
|
||||
@@ -95,7 +95,7 @@ class DefaultJdbcInterpreter implements Interpreter {
|
||||
return;
|
||||
}
|
||||
|
||||
JdbcPersistentEntity<?> persistentEntity = context.getRequiredPersistentEntity(dependingOn.getEntityType());
|
||||
RelationalPersistentEntity<?> persistentEntity = context.getRequiredPersistentEntity(dependingOn.getEntityType());
|
||||
|
||||
String columnName = getColumnNameForReverseColumn(insert, persistentEntity);
|
||||
|
||||
@@ -105,11 +105,11 @@ class DefaultJdbcInterpreter implements Interpreter {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object getIdFromEntityDependingOn(DbAction dependingOn, JdbcPersistentEntity<?> persistentEntity) {
|
||||
private Object getIdFromEntityDependingOn(DbAction dependingOn, RelationalPersistentEntity<?> persistentEntity) {
|
||||
return persistentEntity.getIdentifierAccessor(dependingOn.getEntity()).getIdentifier();
|
||||
}
|
||||
|
||||
private <T> String getColumnNameForReverseColumn(Insert<T> insert, JdbcPersistentEntity<?> persistentEntity) {
|
||||
private <T> String getColumnNameForReverseColumn(Insert<T> insert, RelationalPersistentEntity<?> persistentEntity) {
|
||||
|
||||
PropertyPath path = insert.getPropertyPath().getPath();
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.data.jdbc.core;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.mapping.PropertyPath;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentProperty;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -86,7 +86,7 @@ public class DelegatingDataAccessStrategy implements DataAccessStrategy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Iterable<T> findAllByProperty(Object rootId, JdbcPersistentProperty property) {
|
||||
public <T> Iterable<T> findAllByProperty(Object rootId, RelationalPersistentProperty property) {
|
||||
|
||||
Assert.notNull(delegate, "Delegate is null");
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
import org.springframework.data.mapping.PreferredConstructor.Parameter;
|
||||
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
|
||||
import org.springframework.data.mapping.model.ParameterValueProvider;
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentEntity;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentProperty;
|
||||
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.jdbc.core.RowMapper;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -52,15 +52,15 @@ public class EntityRowMapper<T> implements RowMapper<T> {
|
||||
|
||||
private static final Converter<Iterable<?>, Map<?, ?>> ITERABLE_OF_ENTRY_TO_MAP_CONVERTER = new IterableOfEntryToMapConverter();
|
||||
|
||||
private final JdbcPersistentEntity<T> entity;
|
||||
private final RelationalPersistentEntity<T> entity;
|
||||
|
||||
private final ConversionService conversions;
|
||||
private final JdbcMappingContext context;
|
||||
private final RelationalMappingContext context;
|
||||
private final DataAccessStrategy accessStrategy;
|
||||
private final JdbcPersistentProperty idProperty;
|
||||
private final RelationalPersistentProperty idProperty;
|
||||
private final EntityInstantiators instantiators;
|
||||
|
||||
public EntityRowMapper(JdbcPersistentEntity<T> entity, JdbcMappingContext context, EntityInstantiators instantiators,
|
||||
public EntityRowMapper(RelationalPersistentEntity<T> entity, RelationalMappingContext context, EntityInstantiators instantiators,
|
||||
DataAccessStrategy accessStrategy) {
|
||||
|
||||
this.entity = entity;
|
||||
@@ -85,7 +85,7 @@ public class EntityRowMapper<T> implements RowMapper<T> {
|
||||
|
||||
Object id = idProperty == null ? null : readFrom(resultSet, idProperty, "");
|
||||
|
||||
for (JdbcPersistentProperty property : entity) {
|
||||
for (RelationalPersistentProperty property : entity) {
|
||||
|
||||
if (property.isCollectionLike() && id != null) {
|
||||
propertyAccessor.setProperty(property, accessStrategy.findAllByProperty(id, property));
|
||||
@@ -105,12 +105,12 @@ public class EntityRowMapper<T> implements RowMapper<T> {
|
||||
* Read a single value or a complete Entity from the {@link ResultSet} passed as an argument.
|
||||
*
|
||||
* @param resultSet the {@link ResultSet} to extract the value from. Must not be {@code null}.
|
||||
* @param property the {@link JdbcPersistentProperty} for which the value is intended. Must not be {@code null}.
|
||||
* @param property the {@link RelationalPersistentProperty} for which the value is intended. Must not be {@code null}.
|
||||
* @param prefix to be used for all column names accessed by this method. Must not be {@code null}.
|
||||
* @return the value read from the {@link ResultSet}. May be {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
private Object readFrom(ResultSet resultSet, JdbcPersistentProperty property, String prefix) {
|
||||
private Object readFrom(ResultSet resultSet, RelationalPersistentProperty property, String prefix) {
|
||||
|
||||
try {
|
||||
|
||||
@@ -131,7 +131,7 @@ public class EntityRowMapper<T> implements RowMapper<T> {
|
||||
String prefix = property.getName() + "_";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
JdbcPersistentEntity<S> entity = (JdbcPersistentEntity<S>) context
|
||||
RelationalPersistentEntity<S> entity = (RelationalPersistentEntity<S>) context
|
||||
.getRequiredPersistentEntity(property.getActualType());
|
||||
|
||||
if (readFrom(rs, entity.getRequiredIdProperty(), prefix) == null) {
|
||||
@@ -144,24 +144,24 @@ public class EntityRowMapper<T> implements RowMapper<T> {
|
||||
PersistentPropertyAccessor accessor = entity.getPropertyAccessor(instance);
|
||||
ConvertingPropertyAccessor propertyAccessor = new ConvertingPropertyAccessor(accessor, conversions);
|
||||
|
||||
for (JdbcPersistentProperty p : entity) {
|
||||
for (RelationalPersistentProperty p : entity) {
|
||||
propertyAccessor.setProperty(p, readFrom(rs, p, prefix));
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
private <S> S createInstance(JdbcPersistentEntity<S> entity, ResultSet rs, String prefix) {
|
||||
private <S> S createInstance(RelationalPersistentEntity<S> entity, ResultSet rs, String prefix) {
|
||||
|
||||
return instantiators.getInstantiatorFor(entity) //
|
||||
.createInstance(entity, new ResultSetParameterValueProvider(rs, entity, conversions, prefix));
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
private static class ResultSetParameterValueProvider implements ParameterValueProvider<JdbcPersistentProperty> {
|
||||
private static class ResultSetParameterValueProvider implements ParameterValueProvider<RelationalPersistentProperty> {
|
||||
|
||||
@NonNull private final ResultSet resultSet;
|
||||
@NonNull private final JdbcPersistentEntity<?> entity;
|
||||
@NonNull private final RelationalPersistentEntity<?> entity;
|
||||
@NonNull private final ConversionService conversionService;
|
||||
@NonNull private final String prefix;
|
||||
|
||||
@@ -170,7 +170,7 @@ public class EntityRowMapper<T> implements RowMapper<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 parameterName = parameter.getName();
|
||||
Assert.notNull(parameterName, "A constructor parameter name must not be null to be used with Spring Data JDBC");
|
||||
|
||||
@@ -21,11 +21,11 @@ import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.data.mapping.IdentifierAccessor;
|
||||
import org.springframework.data.relational.core.conversion.AggregateChange;
|
||||
import org.springframework.data.relational.core.conversion.Interpreter;
|
||||
import org.springframework.data.relational.core.conversion.JdbcEntityDeleteWriter;
|
||||
import org.springframework.data.relational.core.conversion.JdbcEntityWriter;
|
||||
import org.springframework.data.relational.core.conversion.RelationalEntityDeleteWriter;
|
||||
import org.springframework.data.relational.core.conversion.RelationalEntityWriter;
|
||||
import org.springframework.data.relational.core.conversion.AggregateChange.Kind;
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentEntity;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
|
||||
import org.springframework.data.relational.core.mapping.event.AfterDeleteEvent;
|
||||
import org.springframework.data.relational.core.mapping.event.AfterLoadEvent;
|
||||
import org.springframework.data.relational.core.mapping.event.AfterSaveEvent;
|
||||
@@ -46,22 +46,22 @@ import org.springframework.util.Assert;
|
||||
public class JdbcAggregateTemplate implements JdbcAggregateOperations {
|
||||
|
||||
private final ApplicationEventPublisher publisher;
|
||||
private final JdbcMappingContext context;
|
||||
private final RelationalMappingContext context;
|
||||
private final Interpreter interpreter;
|
||||
|
||||
private final JdbcEntityWriter jdbcEntityWriter;
|
||||
private final JdbcEntityDeleteWriter jdbcEntityDeleteWriter;
|
||||
private final RelationalEntityWriter jdbcEntityWriter;
|
||||
private final RelationalEntityDeleteWriter jdbcEntityDeleteWriter;
|
||||
|
||||
private final DataAccessStrategy accessStrategy;
|
||||
|
||||
public JdbcAggregateTemplate(ApplicationEventPublisher publisher, JdbcMappingContext context,
|
||||
public JdbcAggregateTemplate(ApplicationEventPublisher publisher, RelationalMappingContext context,
|
||||
DataAccessStrategy dataAccessStrategy) {
|
||||
|
||||
this.publisher = publisher;
|
||||
this.context = context;
|
||||
|
||||
this.jdbcEntityWriter = new JdbcEntityWriter(context);
|
||||
this.jdbcEntityDeleteWriter = new JdbcEntityDeleteWriter(context);
|
||||
this.jdbcEntityWriter = new RelationalEntityWriter(context);
|
||||
this.jdbcEntityDeleteWriter = new RelationalEntityDeleteWriter(context);
|
||||
this.accessStrategy = dataAccessStrategy;
|
||||
this.interpreter = new DefaultJdbcInterpreter(context, accessStrategy);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
|
||||
|
||||
Assert.notNull(instance, "Aggregate instance must not be null!");
|
||||
|
||||
JdbcPersistentEntity<?> entity = context.getRequiredPersistentEntity(instance.getClass());
|
||||
RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(instance.getClass());
|
||||
IdentifierAccessor identifierAccessor = entity.getIdentifierAccessor(instance);
|
||||
|
||||
AggregateChange change = createChange(instance);
|
||||
@@ -192,7 +192,7 @@ public class JdbcAggregateTemplate implements JdbcAggregateOperations {
|
||||
|
||||
for (T e : all) {
|
||||
|
||||
JdbcPersistentEntity<?> entity = context.getRequiredPersistentEntity(e.getClass());
|
||||
RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(e.getClass());
|
||||
IdentifierAccessor identifierAccessor = entity.getIdentifierAccessor(e);
|
||||
|
||||
publishAfterLoad(identifierAccessor.getRequiredIdentifier(), e);
|
||||
|
||||
@@ -27,9 +27,9 @@ import java.util.stream.Stream;
|
||||
import org.springframework.data.jdbc.repository.support.SimpleJdbcRepository;
|
||||
import org.springframework.data.mapping.PropertyHandler;
|
||||
import org.springframework.data.mapping.PropertyPath;
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentEntity;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentProperty;
|
||||
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.Lazy;
|
||||
import org.springframework.data.util.StreamUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -43,8 +43,8 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
class SqlGenerator {
|
||||
|
||||
private final JdbcPersistentEntity<?> entity;
|
||||
private final JdbcMappingContext context;
|
||||
private final RelationalPersistentEntity<?> entity;
|
||||
private final RelationalMappingContext context;
|
||||
private final List<String> columnNames = new ArrayList<>();
|
||||
private final List<String> nonIdColumnNames = new ArrayList<>();
|
||||
|
||||
@@ -61,7 +61,7 @@ class SqlGenerator {
|
||||
private final Lazy<String> deleteByListSql = Lazy.of(this::createDeleteByListSql);
|
||||
private final SqlGeneratorSource sqlGeneratorSource;
|
||||
|
||||
SqlGenerator(JdbcMappingContext context, JdbcPersistentEntity<?> entity, SqlGeneratorSource sqlGeneratorSource) {
|
||||
SqlGenerator(RelationalMappingContext context, RelationalPersistentEntity<?> entity, SqlGeneratorSource sqlGeneratorSource) {
|
||||
|
||||
this.context = context;
|
||||
this.entity = entity;
|
||||
@@ -71,7 +71,7 @@ class SqlGenerator {
|
||||
|
||||
private void initColumnNames() {
|
||||
|
||||
entity.doWithProperties((PropertyHandler<JdbcPersistentProperty>) p -> {
|
||||
entity.doWithProperties((PropertyHandler<RelationalPersistentProperty>) p -> {
|
||||
// the referencing column of referenced entity is expected to be on the other side of the relation
|
||||
if (!p.isEntity()) {
|
||||
columnNames.add(p.getColumnName());
|
||||
@@ -180,7 +180,7 @@ class SqlGenerator {
|
||||
*/
|
||||
private void addColumnsAndJoinsForOneToOneReferences(SelectBuilder builder) {
|
||||
|
||||
for (JdbcPersistentProperty property : entity) {
|
||||
for (RelationalPersistentProperty property : entity) {
|
||||
if (!property.isEntity() //
|
||||
|| Collection.class.isAssignableFrom(property.getType()) //
|
||||
|| Map.class.isAssignableFrom(property.getType()) //
|
||||
@@ -188,12 +188,12 @@ class SqlGenerator {
|
||||
continue;
|
||||
}
|
||||
|
||||
JdbcPersistentEntity<?> refEntity = context.getRequiredPersistentEntity(property.getActualType());
|
||||
RelationalPersistentEntity<?> refEntity = context.getRequiredPersistentEntity(property.getActualType());
|
||||
String joinAlias = property.getName();
|
||||
builder.join(jb -> jb.leftOuter().table(refEntity.getTableName()).as(joinAlias) //
|
||||
.where(property.getReverseColumnName()).eq().column(entity.getTableName(), entity.getIdColumn()));
|
||||
|
||||
for (JdbcPersistentProperty refProperty : refEntity) {
|
||||
for (RelationalPersistentProperty refProperty : refEntity) {
|
||||
builder.column( //
|
||||
cb -> cb.tableAlias(joinAlias) //
|
||||
.column(refProperty.getColumnName()) //
|
||||
@@ -205,7 +205,7 @@ class SqlGenerator {
|
||||
|
||||
private void addColumnsForSimpleProperties(SelectBuilder builder) {
|
||||
|
||||
for (JdbcPersistentProperty property : entity) {
|
||||
for (RelationalPersistentProperty property : entity) {
|
||||
|
||||
if (property.isEntity()) {
|
||||
continue;
|
||||
@@ -224,7 +224,7 @@ class SqlGenerator {
|
||||
.flatMap(p -> getColumnNameStream(p, prefix));
|
||||
}
|
||||
|
||||
private Stream<String> getColumnNameStream(JdbcPersistentProperty p, String prefix) {
|
||||
private Stream<String> getColumnNameStream(RelationalPersistentProperty p, String prefix) {
|
||||
|
||||
if (p.isEntity()) {
|
||||
return sqlGeneratorSource.getSqlGenerator(p.getType()).getColumnNameStream(prefix + p.getColumnName() + "_");
|
||||
@@ -286,10 +286,10 @@ class SqlGenerator {
|
||||
return String.format("DELETE FROM %s", entity.getTableName());
|
||||
}
|
||||
|
||||
JdbcPersistentEntity<?> entityToDelete = context.getRequiredPersistentEntity(path.getLeafType());
|
||||
RelationalPersistentEntity<?> entityToDelete = context.getRequiredPersistentEntity(path.getLeafType());
|
||||
|
||||
JdbcPersistentEntity<?> owningEntity = context.getRequiredPersistentEntity(path.getOwningType());
|
||||
JdbcPersistentProperty property = owningEntity.getRequiredPersistentProperty(path.getSegment());
|
||||
RelationalPersistentEntity<?> owningEntity = context.getRequiredPersistentEntity(path.getOwningType());
|
||||
RelationalPersistentProperty property = owningEntity.getRequiredPersistentProperty(path.getSegment());
|
||||
|
||||
String innerMostCondition = String.format("%s IS NOT NULL", property.getReverseColumnName());
|
||||
|
||||
@@ -304,9 +304,9 @@ class SqlGenerator {
|
||||
|
||||
String createDeleteByPath(PropertyPath path) {
|
||||
|
||||
JdbcPersistentEntity<?> entityToDelete = context.getRequiredPersistentEntity(path.getLeafType());
|
||||
JdbcPersistentEntity<?> owningEntity = context.getRequiredPersistentEntity(path.getOwningType());
|
||||
JdbcPersistentProperty property = owningEntity.getRequiredPersistentProperty(path.getSegment());
|
||||
RelationalPersistentEntity<?> entityToDelete = context.getRequiredPersistentEntity(path.getLeafType());
|
||||
RelationalPersistentEntity<?> owningEntity = context.getRequiredPersistentEntity(path.getOwningType());
|
||||
RelationalPersistentProperty property = owningEntity.getRequiredPersistentProperty(path.getSegment());
|
||||
|
||||
String innerMostCondition = String.format("%s = :rootId", property.getReverseColumnName());
|
||||
|
||||
@@ -321,8 +321,8 @@ class SqlGenerator {
|
||||
return innerCondition;
|
||||
}
|
||||
|
||||
JdbcPersistentEntity<?> entity = context.getRequiredPersistentEntity(path.getOwningType());
|
||||
JdbcPersistentProperty property = entity.getPersistentProperty(path.getSegment());
|
||||
RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(path.getOwningType());
|
||||
RelationalPersistentProperty property = entity.getPersistentProperty(path.getSegment());
|
||||
|
||||
Assert.notNull(property, "could not find property for path " + path.getSegment() + " in " + entity);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
|
||||
/**
|
||||
* Provides {@link SqlGenerator}s per domain type. Instances get cached, so when asked multiple times for the same domain
|
||||
@@ -33,7 +33,7 @@ import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
public class SqlGeneratorSource {
|
||||
|
||||
private final Map<Class, SqlGenerator> sqlGeneratorCache = new HashMap<>();
|
||||
private final JdbcMappingContext context;
|
||||
private final RelationalMappingContext context;
|
||||
|
||||
SqlGenerator getSqlGenerator(Class<?> domainType) {
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ import org.springframework.data.jdbc.core.DefaultDataAccessStrategy;
|
||||
import org.springframework.data.jdbc.core.DelegatingDataAccessStrategy;
|
||||
import org.springframework.data.jdbc.core.SqlGeneratorSource;
|
||||
import org.springframework.data.mapping.PropertyPath;
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentProperty;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy {
|
||||
* Create a {@link DataAccessStrategy} that first checks for queries defined by MyBatis and if it doesn't find one
|
||||
* uses a {@link DefaultDataAccessStrategy}
|
||||
*/
|
||||
public static DataAccessStrategy createCombinedAccessStrategy(JdbcMappingContext context,
|
||||
public static DataAccessStrategy createCombinedAccessStrategy(RelationalMappingContext context,
|
||||
NamedParameterJdbcOperations operations, SqlSession sqlSession) {
|
||||
return createCombinedAccessStrategy(context, new EntityInstantiators(), operations, sqlSession,
|
||||
NamespaceStrategy.DEFAULT_INSTANCE);
|
||||
@@ -67,7 +67,7 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy {
|
||||
* Create a {@link DataAccessStrategy} that first checks for queries defined by MyBatis and if it doesn't find one
|
||||
* uses a {@link DefaultDataAccessStrategy}
|
||||
*/
|
||||
public static DataAccessStrategy createCombinedAccessStrategy(JdbcMappingContext context,
|
||||
public static DataAccessStrategy createCombinedAccessStrategy(RelationalMappingContext context,
|
||||
EntityInstantiators instantiators, NamedParameterJdbcOperations operations, SqlSession sqlSession,
|
||||
NamespaceStrategy namespaceStrategy) {
|
||||
|
||||
@@ -102,7 +102,7 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy {
|
||||
* transaction. Note that the resulting {@link DataAccessStrategy} only handles MyBatis. It does not include the
|
||||
* functionality of the {@link org.springframework.data.jdbc.core.DefaultDataAccessStrategy} which one normally still
|
||||
* wants. Use
|
||||
* {@link #createCombinedAccessStrategy(JdbcMappingContext, EntityInstantiators, NamedParameterJdbcOperations, SqlSession, NamespaceStrategy)}
|
||||
* {@link #createCombinedAccessStrategy(RelationalMappingContext, EntityInstantiators, NamedParameterJdbcOperations, SqlSession, NamespaceStrategy)}
|
||||
* to create such a {@link DataAccessStrategy}.
|
||||
*
|
||||
* @param sqlSession Must be non {@literal null}.
|
||||
@@ -191,7 +191,7 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Iterable<T> findAllByProperty(Object rootId, JdbcPersistentProperty property) {
|
||||
public <T> Iterable<T> findAllByProperty(Object rootId, RelationalPersistentProperty property) {
|
||||
return sqlSession().selectList(
|
||||
namespace(property.getOwner().getType()) + ".findAllByProperty-" + property.getName(),
|
||||
new MyBatisContext(rootId, null, property.getType(), Collections.emptyMap()));
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
|
||||
import org.springframework.data.auditing.IsNewAwareAuditingHandler;
|
||||
import org.springframework.data.auditing.config.AuditingBeanDefinitionRegistrarSupport;
|
||||
import org.springframework.data.auditing.config.AuditingConfiguration;
|
||||
import org.springframework.data.relational.domain.support.JdbcAuditingEventListener;
|
||||
import org.springframework.data.relational.domain.support.RelationalAuditingEventListener;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ class JdbcAuditingRegistrar extends AuditingBeanDefinitionRegistrarSupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the bean definition of {@link JdbcAuditingEventListener}. {@inheritDoc}
|
||||
* Register the bean definition of {@link RelationalAuditingEventListener}. {@inheritDoc}
|
||||
*
|
||||
* @see AuditingBeanDefinitionRegistrarSupport#registerAuditListenerBeanDefinition(BeanDefinition,
|
||||
* BeanDefinitionRegistry)
|
||||
@@ -87,7 +87,7 @@ class JdbcAuditingRegistrar extends AuditingBeanDefinitionRegistrarSupport {
|
||||
protected void registerAuditListenerBeanDefinition(BeanDefinition auditingHandlerDefinition,
|
||||
BeanDefinitionRegistry registry) {
|
||||
|
||||
Class<?> listenerClass = JdbcAuditingEventListener.class;
|
||||
Class<?> listenerClass = RelationalAuditingEventListener.class;
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(listenerClass) //
|
||||
.addConstructorArgReference(AUDITING_HANDLER_BEAN_NAME);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Optional;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.relational.core.mapping.ConversionCustomizer;
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.NamingStrategy;
|
||||
|
||||
/**
|
||||
@@ -34,10 +34,10 @@ import org.springframework.data.relational.core.mapping.NamingStrategy;
|
||||
public class JdbcConfiguration {
|
||||
|
||||
@Bean
|
||||
JdbcMappingContext jdbcMappingContext(Optional<NamingStrategy> namingStrategy,
|
||||
RelationalMappingContext jdbcMappingContext(Optional<NamingStrategy> namingStrategy,
|
||||
Optional<ConversionCustomizer> conversionCustomizer) {
|
||||
|
||||
return new JdbcMappingContext(namingStrategy.orElse(NamingStrategy.INSTANCE),
|
||||
return new RelationalMappingContext(namingStrategy.orElse(NamingStrategy.INSTANCE),
|
||||
conversionCustomizer.orElse(ConversionCustomizer.NONE));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.data.jdbc.core.DataAccessStrategy;
|
||||
import org.springframework.data.jdbc.core.EntityRowMapper;
|
||||
import org.springframework.data.jdbc.repository.RowMapperMap;
|
||||
import org.springframework.data.projection.ProjectionFactory;
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.data.repository.core.NamedQueries;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.query.QueryLookupStrategy;
|
||||
@@ -43,7 +43,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
class JdbcQueryLookupStrategy implements QueryLookupStrategy {
|
||||
|
||||
private final JdbcMappingContext context;
|
||||
private final RelationalMappingContext context;
|
||||
private final EntityInstantiators instantiators;
|
||||
private final DataAccessStrategy accessStrategy;
|
||||
private final RowMapperMap rowMapperMap;
|
||||
@@ -52,14 +52,14 @@ class JdbcQueryLookupStrategy implements QueryLookupStrategy {
|
||||
private final ConversionService conversionService;
|
||||
|
||||
/**
|
||||
* Creates a new {@link JdbcQueryLookupStrategy} for the given {@link JdbcMappingContext}, {@link DataAccessStrategy}
|
||||
* Creates a new {@link JdbcQueryLookupStrategy} for the given {@link RelationalMappingContext}, {@link DataAccessStrategy}
|
||||
* and {@link RowMapperMap}.
|
||||
*
|
||||
* @param context must not be {@literal null}.
|
||||
* @param accessStrategy must not be {@literal null}.
|
||||
* @param rowMapperMap must not be {@literal null}.
|
||||
*/
|
||||
JdbcQueryLookupStrategy(JdbcMappingContext context, EntityInstantiators instantiators,
|
||||
JdbcQueryLookupStrategy(RelationalMappingContext context, EntityInstantiators instantiators,
|
||||
DataAccessStrategy accessStrategy, RowMapperMap rowMapperMap, NamedParameterJdbcOperations operations) {
|
||||
|
||||
Assert.notNull(context, "JdbcMappingContext must not be null!");
|
||||
|
||||
@@ -22,8 +22,8 @@ import org.springframework.data.convert.EntityInstantiators;
|
||||
import org.springframework.data.jdbc.core.DataAccessStrategy;
|
||||
import org.springframework.data.jdbc.core.JdbcAggregateTemplate;
|
||||
import org.springframework.data.jdbc.repository.RowMapperMap;
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentEntity;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
|
||||
import org.springframework.data.repository.core.EntityInformation;
|
||||
import org.springframework.data.repository.core.RepositoryInformation;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
@@ -45,7 +45,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class JdbcRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
private final JdbcMappingContext context;
|
||||
private final RelationalMappingContext context;
|
||||
private final ApplicationEventPublisher publisher;
|
||||
private final DataAccessStrategy accessStrategy;
|
||||
private final NamedParameterJdbcOperations operations;
|
||||
@@ -54,7 +54,7 @@ public class JdbcRepositoryFactory extends RepositoryFactorySupport {
|
||||
private EntityInstantiators instantiators = new EntityInstantiators();
|
||||
|
||||
/**
|
||||
* Creates a new {@link JdbcRepositoryFactory} for the given {@link DataAccessStrategy}, {@link JdbcMappingContext}
|
||||
* Creates a new {@link JdbcRepositoryFactory} for the given {@link DataAccessStrategy}, {@link RelationalMappingContext}
|
||||
* and {@link ApplicationEventPublisher}.
|
||||
*
|
||||
* @param dataAccessStrategy must not be {@literal null}.
|
||||
@@ -62,7 +62,7 @@ public class JdbcRepositoryFactory extends RepositoryFactorySupport {
|
||||
* @param publisher must not be {@literal null}.
|
||||
* @param operations must not be {@literal null}.
|
||||
*/
|
||||
public JdbcRepositoryFactory(DataAccessStrategy dataAccessStrategy, JdbcMappingContext context,
|
||||
public JdbcRepositoryFactory(DataAccessStrategy dataAccessStrategy, RelationalMappingContext context,
|
||||
ApplicationEventPublisher publisher, NamedParameterJdbcOperations operations) {
|
||||
|
||||
Assert.notNull(dataAccessStrategy, "DataAccessStrategy must not be null!");
|
||||
@@ -101,7 +101,7 @@ public class JdbcRepositoryFactory extends RepositoryFactorySupport {
|
||||
@Override
|
||||
public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> aClass) {
|
||||
|
||||
JdbcPersistentEntity<?> entity = context.getPersistentEntity(aClass);
|
||||
RelationalPersistentEntity<?> entity = context.getPersistentEntity(aClass);
|
||||
|
||||
if (entity == null) {
|
||||
return null;
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.data.jdbc.core.DataAccessStrategy;
|
||||
import org.springframework.data.jdbc.core.DefaultDataAccessStrategy;
|
||||
import org.springframework.data.jdbc.core.SqlGeneratorSource;
|
||||
import org.springframework.data.jdbc.repository.RowMapperMap;
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
|
||||
import org.springframework.data.repository.core.support.TransactionalRepositoryFactoryBeanSupport;
|
||||
@@ -46,7 +46,7 @@ public class JdbcRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extend
|
||||
extends TransactionalRepositoryFactoryBeanSupport<T, S, ID> implements ApplicationEventPublisherAware {
|
||||
|
||||
private ApplicationEventPublisher publisher;
|
||||
private JdbcMappingContext mappingContext;
|
||||
private RelationalMappingContext mappingContext;
|
||||
private DataAccessStrategy dataAccessStrategy;
|
||||
private RowMapperMap rowMapperMap = RowMapperMap.EMPTY;
|
||||
private NamedParameterJdbcOperations operations;
|
||||
@@ -87,7 +87,7 @@ public class JdbcRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extend
|
||||
}
|
||||
|
||||
@Autowired
|
||||
protected void setMappingContext(JdbcMappingContext mappingContext) {
|
||||
protected void setMappingContext(RelationalMappingContext mappingContext) {
|
||||
|
||||
super.setMappingContext(mappingContext);
|
||||
this.mappingContext = mappingContext;
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.jdbc.repository.support;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.data.repository.query.RepositoryQuery;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
@@ -44,7 +44,7 @@ class JdbcRepositoryQuery implements RepositoryQuery {
|
||||
private final RowMapper<?> rowMapper;
|
||||
|
||||
/**
|
||||
* Creates a new {@link JdbcRepositoryQuery} for the given {@link JdbcQueryMethod}, {@link JdbcMappingContext} and
|
||||
* Creates a new {@link JdbcRepositoryQuery} for the given {@link JdbcQueryMethod}, {@link RelationalMappingContext} and
|
||||
* {@link RowMapper}.
|
||||
*
|
||||
* @param queryMethod must not be {@literal null}.
|
||||
|
||||
@@ -47,7 +47,7 @@ public abstract class DbAction<T> {
|
||||
/**
|
||||
* The path from the Aggregate Root to the entity affected by this {@link DbAction}.
|
||||
*/
|
||||
private final JdbcPropertyPath propertyPath;
|
||||
private final RelationalPropertyPath propertyPath;
|
||||
|
||||
/**
|
||||
* Key-value-pairs to specify additional values to be used with the statement which can't be obtained from the entity,
|
||||
@@ -63,7 +63,7 @@ public abstract class DbAction<T> {
|
||||
*/
|
||||
private final DbAction dependingOn;
|
||||
|
||||
private DbAction(Class<T> entityType, @Nullable T entity, @Nullable JdbcPropertyPath propertyPath,
|
||||
private DbAction(Class<T> entityType, @Nullable T entity, @Nullable RelationalPropertyPath propertyPath,
|
||||
@Nullable DbAction dependingOn) {
|
||||
|
||||
Assert.notNull(entityType, "entityType must not be null");
|
||||
@@ -84,7 +84,7 @@ public abstract class DbAction<T> {
|
||||
* @param <T> the type of the entity to be inserted.
|
||||
* @return a {@link DbAction} representing the insert.
|
||||
*/
|
||||
public static <T> Insert<T> insert(T entity, JdbcPropertyPath propertyPath, @Nullable DbAction dependingOn) {
|
||||
public static <T> Insert<T> insert(T entity, RelationalPropertyPath propertyPath, @Nullable DbAction dependingOn) {
|
||||
return new Insert<>(entity, propertyPath, dependingOn);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public abstract class DbAction<T> {
|
||||
* @param <T> the type of the entity to be updated.
|
||||
* @return a {@link DbAction} representing the update.
|
||||
*/
|
||||
public static <T> Update<T> update(T entity, JdbcPropertyPath propertyPath, @Nullable DbAction dependingOn) {
|
||||
public static <T> Update<T> update(T entity, RelationalPropertyPath propertyPath, @Nullable DbAction dependingOn) {
|
||||
return new Update<>(entity, propertyPath, dependingOn);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public abstract class DbAction<T> {
|
||||
* @return a {@link DbAction} representing the deletion of the entity with given type and id.
|
||||
*/
|
||||
public static <T> Delete<T> delete(Object id, Class<T> type, @Nullable T entity,
|
||||
@Nullable JdbcPropertyPath propertyPath, @Nullable DbAction dependingOn) {
|
||||
@Nullable RelationalPropertyPath propertyPath, @Nullable DbAction dependingOn) {
|
||||
return new Delete<>(id, type, entity, propertyPath, dependingOn);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public abstract class DbAction<T> {
|
||||
* @return a {@link DbAction} representing the deletion of all entities of a given type belonging to a specific type
|
||||
* of aggregate root.
|
||||
*/
|
||||
public static <T> DeleteAll<T> deleteAll(Class<T> type, @Nullable JdbcPropertyPath propertyPath,
|
||||
public static <T> DeleteAll<T> deleteAll(Class<T> type, @Nullable RelationalPropertyPath propertyPath,
|
||||
@Nullable DbAction dependingOn) {
|
||||
return new DeleteAll<>(type, propertyPath, dependingOn);
|
||||
}
|
||||
@@ -163,7 +163,7 @@ public abstract class DbAction<T> {
|
||||
abstract static class InsertOrUpdate<T> extends DbAction<T> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
InsertOrUpdate(T entity, JdbcPropertyPath propertyPath, @Nullable DbAction dependingOn) {
|
||||
InsertOrUpdate(T entity, RelationalPropertyPath propertyPath, @Nullable DbAction dependingOn) {
|
||||
super((Class<T>) entity.getClass(), entity, propertyPath, dependingOn);
|
||||
}
|
||||
}
|
||||
@@ -175,7 +175,7 @@ public abstract class DbAction<T> {
|
||||
*/
|
||||
public static class Insert<T> extends InsertOrUpdate<T> {
|
||||
|
||||
private Insert(T entity, JdbcPropertyPath propertyPath, @Nullable DbAction dependingOn) {
|
||||
private Insert(T entity, RelationalPropertyPath propertyPath, @Nullable DbAction dependingOn) {
|
||||
super(entity, propertyPath, dependingOn);
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ public abstract class DbAction<T> {
|
||||
*/
|
||||
public static class Update<T> extends InsertOrUpdate<T> {
|
||||
|
||||
private Update(T entity, JdbcPropertyPath propertyPath, @Nullable DbAction dependingOn) {
|
||||
private Update(T entity, RelationalPropertyPath propertyPath, @Nullable DbAction dependingOn) {
|
||||
super(entity, propertyPath, dependingOn);
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ public abstract class DbAction<T> {
|
||||
*/
|
||||
private final Object rootId;
|
||||
|
||||
private Delete(@Nullable Object rootId, Class<T> type, @Nullable T entity, @Nullable JdbcPropertyPath propertyPath,
|
||||
private Delete(@Nullable Object rootId, Class<T> type, @Nullable T entity, @Nullable RelationalPropertyPath propertyPath,
|
||||
@Nullable DbAction dependingOn) {
|
||||
|
||||
super(type, entity, propertyPath, dependingOn);
|
||||
@@ -239,7 +239,7 @@ public abstract class DbAction<T> {
|
||||
*/
|
||||
public static class DeleteAll<T> extends DbAction<T> {
|
||||
|
||||
private DeleteAll(Class<T> entityType, @Nullable JdbcPropertyPath propertyPath, @Nullable DbAction dependingOn) {
|
||||
private DeleteAll(Class<T> entityType, @Nullable RelationalPropertyPath propertyPath, @Nullable DbAction dependingOn) {
|
||||
super(entityType, null, propertyPath, dependingOn);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.relational.core.conversion;
|
||||
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
@@ -25,9 +25,9 @@ import org.springframework.lang.Nullable;
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public class JdbcEntityDeleteWriter extends JdbcEntityWriterSupport {
|
||||
public class RelationalEntityDeleteWriter extends RelationalEntityWriterSupport {
|
||||
|
||||
public JdbcEntityDeleteWriter(JdbcMappingContext context) {
|
||||
public RelationalEntityDeleteWriter(RelationalMappingContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class JdbcEntityDeleteWriter extends JdbcEntityWriterSupport {
|
||||
private void deleteAll(AggregateChange<?> aggregateChange) {
|
||||
|
||||
context.referencedEntities(aggregateChange.getEntityType(), null)
|
||||
.forEach(p -> aggregateChange.addAction(DbAction.deleteAll(p.getLeafType(), new JdbcPropertyPath(p), null)));
|
||||
.forEach(p -> aggregateChange.addAction(DbAction.deleteAll(p.getLeafType(), new RelationalPropertyPath(p), null)));
|
||||
|
||||
aggregateChange.addAction(DbAction.deleteAll(aggregateChange.getEntityType(), null, null));
|
||||
}
|
||||
@@ -29,9 +29,9 @@ import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
import org.springframework.data.relational.core.conversion.DbAction.Insert;
|
||||
import org.springframework.data.relational.core.conversion.DbAction.Update;
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentEntity;
|
||||
import org.springframework.data.relational.core.mapping.JdbcPersistentProperty;
|
||||
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.StreamUtils;
|
||||
|
||||
/**
|
||||
@@ -41,11 +41,11 @@ import org.springframework.data.util.StreamUtils;
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public class JdbcEntityWriter extends JdbcEntityWriterSupport {
|
||||
public class RelationalEntityWriter extends RelationalEntityWriterSupport {
|
||||
|
||||
private final JdbcMappingContext context;
|
||||
private final RelationalMappingContext context;
|
||||
|
||||
public JdbcEntityWriter(JdbcMappingContext context) {
|
||||
public RelationalEntityWriter(RelationalMappingContext context) {
|
||||
|
||||
super(context);
|
||||
|
||||
@@ -63,9 +63,9 @@ public class JdbcEntityWriter extends JdbcEntityWriterSupport {
|
||||
public void write(Object aggregateRoot, AggregateChange aggregateChange) {
|
||||
|
||||
Class<?> type = aggregateRoot.getClass();
|
||||
JdbcPropertyPath propertyPath = JdbcPropertyPath.from("", type);
|
||||
RelationalPropertyPath propertyPath = RelationalPropertyPath.from("", type);
|
||||
|
||||
PersistentEntity<?, JdbcPersistentProperty> persistentEntity = context.getRequiredPersistentEntity(type);
|
||||
PersistentEntity<?, RelationalPersistentProperty> persistentEntity = context.getRequiredPersistentEntity(type);
|
||||
|
||||
if (persistentEntity.isNew(aggregateRoot)) {
|
||||
|
||||
@@ -83,7 +83,7 @@ public class JdbcEntityWriter extends JdbcEntityWriterSupport {
|
||||
);
|
||||
} else {
|
||||
|
||||
JdbcPersistentEntity<?> entity = context.getRequiredPersistentEntity(type);
|
||||
RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(type);
|
||||
IdentifierAccessor identifierAccessor = entity.getIdentifierAccessor(aggregateRoot);
|
||||
|
||||
deleteReferencedEntities(identifierAccessor.getRequiredIdentifier(), aggregateChange);
|
||||
@@ -97,7 +97,7 @@ public class JdbcEntityWriter extends JdbcEntityWriterSupport {
|
||||
}
|
||||
|
||||
private void insertReferencedEntities(PropertyAndValue propertyAndValue, AggregateChange aggregateChange,
|
||||
JdbcPropertyPath propertyPath, DbAction dependingOn) {
|
||||
RelationalPropertyPath propertyPath, DbAction dependingOn) {
|
||||
|
||||
Insert<Object> insert;
|
||||
if (propertyAndValue.property.isQualified()) {
|
||||
@@ -121,7 +121,7 @@ public class JdbcEntityWriter extends JdbcEntityWriterSupport {
|
||||
|
||||
private Stream<PropertyAndValue> referencedEntities(Object o) {
|
||||
|
||||
JdbcPersistentEntity<?> persistentEntity = context.getRequiredPersistentEntity(o.getClass());
|
||||
RelationalPersistentEntity<?> persistentEntity = context.getRequiredPersistentEntity(o.getClass());
|
||||
|
||||
return StreamUtils.createStreamFromIterator(persistentEntity.iterator()) //
|
||||
.filter(PersistentProperty::isEntity) //
|
||||
@@ -131,10 +131,10 @@ public class JdbcEntityWriter extends JdbcEntityWriterSupport {
|
||||
);
|
||||
}
|
||||
|
||||
private Stream<Object> referencedEntity(JdbcPersistentProperty p, PersistentPropertyAccessor propertyAccessor) {
|
||||
private Stream<Object> referencedEntity(RelationalPersistentProperty p, PersistentPropertyAccessor propertyAccessor) {
|
||||
|
||||
Class<?> actualType = p.getActualType();
|
||||
JdbcPersistentEntity<?> persistentEntity = context //
|
||||
RelationalPersistentEntity<?> persistentEntity = context //
|
||||
.getPersistentEntity(actualType);
|
||||
|
||||
if (persistentEntity == null) {
|
||||
@@ -159,7 +159,7 @@ public class JdbcEntityWriter extends JdbcEntityWriterSupport {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Stream<Object> collectionPropertyAsStream(JdbcPersistentProperty p,
|
||||
private Stream<Object> collectionPropertyAsStream(RelationalPersistentProperty p,
|
||||
PersistentPropertyAccessor propertyAccessor) {
|
||||
|
||||
Object property = propertyAccessor.getProperty(p);
|
||||
@@ -170,7 +170,7 @@ public class JdbcEntityWriter extends JdbcEntityWriterSupport {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Stream<Object> listPropertyAsStream(JdbcPersistentProperty p, PersistentPropertyAccessor propertyAccessor) {
|
||||
private Stream<Object> listPropertyAsStream(RelationalPersistentProperty p, PersistentPropertyAccessor propertyAccessor) {
|
||||
|
||||
Object property = propertyAccessor.getProperty(p);
|
||||
|
||||
@@ -186,7 +186,7 @@ public class JdbcEntityWriter extends JdbcEntityWriterSupport {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Stream<Object> mapPropertyAsStream(JdbcPersistentProperty p, PersistentPropertyAccessor propertyAccessor) {
|
||||
private Stream<Object> mapPropertyAsStream(RelationalPersistentProperty p, PersistentPropertyAccessor propertyAccessor) {
|
||||
|
||||
Object property = propertyAccessor.getProperty(p);
|
||||
|
||||
@@ -195,7 +195,7 @@ public class JdbcEntityWriter extends JdbcEntityWriterSupport {
|
||||
: ((Map<Object, Object>) property).entrySet().stream().map(e -> new KeyValue(e.getKey(), e.getValue()));
|
||||
}
|
||||
|
||||
private Stream<Object> singlePropertyAsStream(JdbcPersistentProperty p, PersistentPropertyAccessor propertyAccessor) {
|
||||
private Stream<Object> singlePropertyAsStream(RelationalPersistentProperty p, PersistentPropertyAccessor propertyAccessor) {
|
||||
|
||||
Object property = propertyAccessor.getProperty(p);
|
||||
if (property == null) {
|
||||
@@ -217,7 +217,7 @@ public class JdbcEntityWriter extends JdbcEntityWriterSupport {
|
||||
@Data
|
||||
private static class PropertyAndValue {
|
||||
|
||||
private final JdbcPersistentProperty property;
|
||||
private final RelationalPersistentProperty property;
|
||||
private final Object value;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
package org.springframework.data.relational.core.conversion;
|
||||
|
||||
import org.springframework.data.convert.EntityWriter;
|
||||
import org.springframework.data.relational.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -25,10 +25,10 @@ import org.springframework.util.Assert;
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
abstract class JdbcEntityWriterSupport implements EntityWriter<Object, AggregateChange<?>> {
|
||||
protected final JdbcMappingContext context;
|
||||
abstract class RelationalEntityWriterSupport implements EntityWriter<Object, AggregateChange<?>> {
|
||||
protected final RelationalMappingContext context;
|
||||
|
||||
JdbcEntityWriterSupport(JdbcMappingContext context) {
|
||||
RelationalEntityWriterSupport(RelationalMappingContext context) {
|
||||
|
||||
Assert.notNull(context, "Context must not be null");
|
||||
|
||||
@@ -45,6 +45,6 @@ abstract class JdbcEntityWriterSupport implements EntityWriter<Object, Aggregate
|
||||
void deleteReferencedEntities(Object id, AggregateChange<?> aggregateChange) {
|
||||
|
||||
context.referencedEntities(aggregateChange.getEntityType(), null).forEach(
|
||||
p -> aggregateChange.addAction(DbAction.delete(id, p.getLeafType(), null, new JdbcPropertyPath(p), null)));
|
||||
p -> aggregateChange.addAction(DbAction.delete(id, p.getLeafType(), null, new RelationalPropertyPath(p), null)));
|
||||
}
|
||||
}
|
||||
@@ -26,12 +26,12 @@ import org.springframework.util.StringUtils;
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public class JdbcPropertyPath {
|
||||
public class RelationalPropertyPath {
|
||||
|
||||
private final PropertyPath path;
|
||||
private final Class<?> rootType;
|
||||
|
||||
JdbcPropertyPath(PropertyPath path) {
|
||||
RelationalPropertyPath(PropertyPath path) {
|
||||
|
||||
Assert.notNull(path, "path must not be null if rootType is not set");
|
||||
|
||||
@@ -39,7 +39,7 @@ public class JdbcPropertyPath {
|
||||
this.rootType = null;
|
||||
}
|
||||
|
||||
private JdbcPropertyPath(Class<?> type) {
|
||||
private RelationalPropertyPath(Class<?> type) {
|
||||
|
||||
Assert.notNull(type, "type must not be null if path is not set");
|
||||
|
||||
@@ -47,20 +47,20 @@ public class JdbcPropertyPath {
|
||||
this.rootType = type;
|
||||
}
|
||||
|
||||
public static JdbcPropertyPath from(String source, Class<?> type) {
|
||||
public static RelationalPropertyPath from(String source, Class<?> type) {
|
||||
|
||||
if (StringUtils.isEmpty(source)) {
|
||||
return new JdbcPropertyPath(type);
|
||||
return new RelationalPropertyPath(type);
|
||||
} else {
|
||||
return new JdbcPropertyPath(PropertyPath.from(source, type));
|
||||
return new RelationalPropertyPath(PropertyPath.from(source, type));
|
||||
}
|
||||
}
|
||||
|
||||
public JdbcPropertyPath nested(String name) {
|
||||
public RelationalPropertyPath nested(String name) {
|
||||
|
||||
return path == null ? //
|
||||
new JdbcPropertyPath(PropertyPath.from(name, rootType)) //
|
||||
: new JdbcPropertyPath(path.nested(name));
|
||||
new RelationalPropertyPath(PropertyPath.from(name, rootType)) //
|
||||
: new RelationalPropertyPath(path.nested(name));
|
||||
}
|
||||
|
||||
public PropertyPath getPath() {
|
||||
@@ -40,8 +40,8 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Greg Turnquist
|
||||
* @since 1.0
|
||||
*/
|
||||
class BasicJdbcPersistentProperty extends AnnotationBasedPersistentProperty<JdbcPersistentProperty>
|
||||
implements JdbcPersistentProperty {
|
||||
class BasicRelationalPersistentProperty extends AnnotationBasedPersistentProperty<RelationalPersistentProperty>
|
||||
implements RelationalPersistentProperty {
|
||||
|
||||
private static final Map<Class<?>, Class<?>> javaToDbType = new LinkedHashMap<>();
|
||||
|
||||
@@ -51,7 +51,7 @@ class BasicJdbcPersistentProperty extends AnnotationBasedPersistentProperty<Jdbc
|
||||
javaToDbType.put(Temporal.class, Date.class);
|
||||
}
|
||||
|
||||
private final JdbcMappingContext context;
|
||||
private final RelationalMappingContext context;
|
||||
private final Lazy<Optional<String>> columnName;
|
||||
|
||||
/**
|
||||
@@ -62,8 +62,8 @@ class BasicJdbcPersistentProperty extends AnnotationBasedPersistentProperty<Jdbc
|
||||
* @param simpleTypeHolder must not be {@literal null}.
|
||||
* @param context must not be {@literal null}
|
||||
*/
|
||||
public BasicJdbcPersistentProperty(Property property, PersistentEntity<?, JdbcPersistentProperty> owner,
|
||||
SimpleTypeHolder simpleTypeHolder, JdbcMappingContext context) {
|
||||
public BasicRelationalPersistentProperty(Property property, PersistentEntity<?, RelationalPersistentProperty> owner,
|
||||
SimpleTypeHolder simpleTypeHolder, RelationalMappingContext context) {
|
||||
|
||||
super(property, owner, simpleTypeHolder);
|
||||
|
||||
@@ -78,7 +78,7 @@ class BasicJdbcPersistentProperty extends AnnotationBasedPersistentProperty<Jdbc
|
||||
* @see org.springframework.data.mapping.model.AbstractPersistentProperty#createAssociation()
|
||||
*/
|
||||
@Override
|
||||
protected Association<JdbcPersistentProperty> createAssociation() {
|
||||
protected Association<RelationalPersistentProperty> createAssociation() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ class BasicJdbcPersistentProperty extends AnnotationBasedPersistentProperty<Jdbc
|
||||
}
|
||||
|
||||
@Override
|
||||
public JdbcPersistentEntity<?> getOwner() {
|
||||
return (JdbcPersistentEntity<?>) super.getOwner();
|
||||
public RelationalPersistentEntity<?> getOwner() {
|
||||
return (RelationalPersistentEntity<?>) super.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,13 +137,13 @@ class BasicJdbcPersistentProperty extends AnnotationBasedPersistentProperty<Jdbc
|
||||
@Nullable
|
||||
private Class columnTypeIfEntity(Class type) {
|
||||
|
||||
JdbcPersistentEntity<?> persistentEntity = context.getPersistentEntity(type);
|
||||
RelationalPersistentEntity<?> persistentEntity = context.getPersistentEntity(type);
|
||||
|
||||
if (persistentEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
JdbcPersistentProperty idProperty = persistentEntity.getIdProperty();
|
||||
RelationalPersistentProperty idProperty = persistentEntity.getIdProperty();
|
||||
|
||||
if (idProperty == null) {
|
||||
return null;
|
||||
@@ -20,7 +20,7 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Interface and default implementation of a naming strategy. Defaults to no schema, table name based on {@link Class}
|
||||
* and column name based on {@link JdbcPersistentProperty} with name parts of both separated by '_'.
|
||||
* and column name based on {@link RelationalPersistentProperty} with name parts of both separated by '_'.
|
||||
* <p>
|
||||
* NOTE: Can also be used as an adapter. Create a lambda or an anonymous subclass and override any settings to implement
|
||||
* a different strategy on the fly.
|
||||
@@ -62,10 +62,10 @@ public interface NamingStrategy {
|
||||
}
|
||||
|
||||
/**
|
||||
* Defaults to return the given {@link JdbcPersistentProperty}'s name with the parts of a camel case name separated by
|
||||
* Defaults to return the given {@link RelationalPersistentProperty}'s name with the parts of a camel case name separated by
|
||||
* '_';
|
||||
*/
|
||||
default String getColumnName(JdbcPersistentProperty property) {
|
||||
default String getColumnName(RelationalPersistentProperty property) {
|
||||
|
||||
Assert.notNull(property, "Property must not be null.");
|
||||
|
||||
@@ -82,7 +82,7 @@ public interface NamingStrategy {
|
||||
* @param property The property who's column name in the owner table is required
|
||||
* @return a column name. Must not be {@code null}.
|
||||
*/
|
||||
default String getReverseColumnName(JdbcPersistentProperty property) {
|
||||
default String getReverseColumnName(RelationalPersistentProperty property) {
|
||||
|
||||
Assert.notNull(property, "Property must not be null.");
|
||||
|
||||
@@ -95,7 +95,7 @@ public interface NamingStrategy {
|
||||
*
|
||||
* @return name of the key column. Must not be {@code null}.
|
||||
*/
|
||||
default String getKeyColumn(JdbcPersistentProperty property) {
|
||||
default String getKeyColumn(RelationalPersistentProperty property) {
|
||||
|
||||
Assert.notNull(property, "Property must not be null.");
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ import org.springframework.util.Assert;
|
||||
* @author Oliver Gierke
|
||||
* @since 1.0
|
||||
*/
|
||||
public class JdbcMappingContext extends AbstractMappingContext<JdbcPersistentEntity<?>, JdbcPersistentProperty> {
|
||||
public class RelationalMappingContext extends AbstractMappingContext<RelationalPersistentEntity<?>, RelationalPersistentProperty> {
|
||||
|
||||
private static final HashSet<Class<?>> CUSTOM_SIMPLE_TYPES = new HashSet<>(asList( //
|
||||
BigDecimal.class, //
|
||||
@@ -62,23 +62,23 @@ public class JdbcMappingContext extends AbstractMappingContext<JdbcPersistentEnt
|
||||
@Getter private SimpleTypeHolder simpleTypeHolder;
|
||||
|
||||
/**
|
||||
* Creates a new {@link JdbcMappingContext}.
|
||||
* Creates a new {@link RelationalMappingContext}.
|
||||
*/
|
||||
public JdbcMappingContext() {
|
||||
public RelationalMappingContext() {
|
||||
this(NamingStrategy.INSTANCE, ConversionCustomizer.NONE);
|
||||
}
|
||||
|
||||
public JdbcMappingContext(NamingStrategy namingStrategy) {
|
||||
public RelationalMappingContext(NamingStrategy namingStrategy) {
|
||||
this(namingStrategy, ConversionCustomizer.NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link JdbcMappingContext} using the given {@link NamingStrategy} and {@link ConversionCustomizer}.
|
||||
* Creates a new {@link RelationalMappingContext} using the given {@link NamingStrategy} and {@link ConversionCustomizer}.
|
||||
*
|
||||
* @param namingStrategy must not be {@literal null}.
|
||||
* @param customizer must not be {@literal null}.
|
||||
*/
|
||||
public JdbcMappingContext(NamingStrategy namingStrategy, ConversionCustomizer customizer) {
|
||||
public RelationalMappingContext(NamingStrategy namingStrategy, ConversionCustomizer customizer) {
|
||||
|
||||
Assert.notNull(namingStrategy, "NamingStrategy must not be null!");
|
||||
Assert.notNull(customizer, "ConversionCustomizer must not be null!");
|
||||
@@ -112,9 +112,9 @@ public class JdbcMappingContext extends AbstractMappingContext<JdbcPersistentEnt
|
||||
List<PropertyPath> paths = new ArrayList<>();
|
||||
|
||||
Class<?> currentType = path == null ? rootType : path.getLeafType();
|
||||
JdbcPersistentEntity<?> persistentEntity = getRequiredPersistentEntity(currentType);
|
||||
RelationalPersistentEntity<?> persistentEntity = getRequiredPersistentEntity(currentType);
|
||||
|
||||
for (JdbcPersistentProperty property : persistentEntity) {
|
||||
for (RelationalPersistentProperty property : persistentEntity) {
|
||||
if (property.isEntity()) {
|
||||
|
||||
PropertyPath nextPath = path == null ? PropertyPath.from(property.getName(), rootType)
|
||||
@@ -134,8 +134,8 @@ public class JdbcMappingContext extends AbstractMappingContext<JdbcPersistentEnt
|
||||
* @see org.springframework.data.mapping.context.AbstractMappingContext#createPersistentEntity(org.springframework.data.util.TypeInformation)
|
||||
*/
|
||||
@Override
|
||||
protected <T> JdbcPersistentEntity<T> createPersistentEntity(TypeInformation<T> typeInformation) {
|
||||
return new JdbcPersistentEntityImpl<>(typeInformation, this.namingStrategy);
|
||||
protected <T> RelationalPersistentEntity<T> createPersistentEntity(TypeInformation<T> typeInformation) {
|
||||
return new RelationalPersistentEntityImpl<>(typeInformation, this.namingStrategy);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -143,9 +143,9 @@ public class JdbcMappingContext extends AbstractMappingContext<JdbcPersistentEnt
|
||||
* @see org.springframework.data.mapping.context.AbstractMappingContext#createPersistentProperty(org.springframework.data.mapping.model.Property, org.springframework.data.mapping.model.MutablePersistentEntity, org.springframework.data.mapping.model.SimpleTypeHolder)
|
||||
*/
|
||||
@Override
|
||||
protected JdbcPersistentProperty createPersistentProperty(Property property, JdbcPersistentEntity<?> owner,
|
||||
protected RelationalPersistentProperty createPersistentProperty(Property property, RelationalPersistentEntity<?> owner,
|
||||
SimpleTypeHolder simpleTypeHolder) {
|
||||
return new BasicJdbcPersistentProperty(property, owner, simpleTypeHolder, this);
|
||||
return new BasicRelationalPersistentProperty(property, owner, simpleTypeHolder, this);
|
||||
}
|
||||
|
||||
public ConversionService getConversions() {
|
||||
@@ -25,7 +25,7 @@ import org.springframework.data.mapping.model.MutablePersistentEntity;
|
||||
* @author Oliver Gierke
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface JdbcPersistentEntity<T> extends MutablePersistentEntity<T, JdbcPersistentProperty> {
|
||||
public interface RelationalPersistentEntity<T> extends MutablePersistentEntity<T, RelationalPersistentProperty> {
|
||||
|
||||
/**
|
||||
* Returns the name of the table backing the given entity.
|
||||
@@ -28,18 +28,18 @@ import org.springframework.data.util.TypeInformation;
|
||||
* @author Greg Turnquist
|
||||
* @since 1.0
|
||||
*/
|
||||
class JdbcPersistentEntityImpl<T> extends BasicPersistentEntity<T, JdbcPersistentProperty>
|
||||
implements JdbcPersistentEntity<T> {
|
||||
class RelationalPersistentEntityImpl<T> extends BasicPersistentEntity<T, RelationalPersistentProperty>
|
||||
implements RelationalPersistentEntity<T> {
|
||||
|
||||
private final NamingStrategy namingStrategy;
|
||||
private final Lazy<Optional<String>> tableName;
|
||||
|
||||
/**
|
||||
* Creates a new {@link JdbcPersistentEntityImpl} for the given {@link TypeInformation}.
|
||||
* Creates a new {@link RelationalPersistentEntityImpl} for the given {@link TypeInformation}.
|
||||
*
|
||||
* @param information must not be {@literal null}.
|
||||
*/
|
||||
JdbcPersistentEntityImpl(TypeInformation<T> information, NamingStrategy namingStrategy) {
|
||||
RelationalPersistentEntityImpl(TypeInformation<T> information, NamingStrategy namingStrategy) {
|
||||
|
||||
super(information);
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.lang.Nullable;
|
||||
* @author Oliver Gierke
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface JdbcPersistentProperty extends PersistentProperty<JdbcPersistentProperty> {
|
||||
public interface RelationalPersistentProperty extends PersistentProperty<RelationalPersistentProperty> {
|
||||
|
||||
/**
|
||||
* Returns the name of the column backing this property.
|
||||
@@ -42,7 +42,7 @@ public interface JdbcPersistentProperty extends PersistentProperty<JdbcPersisten
|
||||
Class<?> getColumnType();
|
||||
|
||||
@Override
|
||||
JdbcPersistentEntity<?> getOwner();
|
||||
RelationalPersistentEntity<?> getOwner();
|
||||
|
||||
String getReverseColumnName();
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.data.relational.core.mapping.event.Identifier.Specifi
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public class AfterDeleteEvent extends JdbcEventWithId {
|
||||
public class AfterDeleteEvent extends RelationalEventWithId {
|
||||
|
||||
private static final long serialVersionUID = 3594807189931141582L;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.data.relational.core.mapping.event.Identifier.Specifi
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public class AfterLoadEvent extends JdbcEventWithIdAndEntity {
|
||||
public class AfterLoadEvent extends RelationalEventWithIdAndEntity {
|
||||
|
||||
private static final long serialVersionUID = -4185777271143436728L;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.data.relational.core.mapping.event.Identifier.Specifi
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public class AfterSaveEvent extends JdbcEventWithIdAndEntity {
|
||||
public class AfterSaveEvent extends RelationalEventWithIdAndEntity {
|
||||
|
||||
private static final long serialVersionUID = 8982085767296982848L;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.data.relational.core.mapping.event.Identifier.Specifi
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public class BeforeDeleteEvent extends JdbcEventWithId {
|
||||
public class BeforeDeleteEvent extends RelationalEventWithId {
|
||||
|
||||
private static final long serialVersionUID = -5483432053368496651L;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.data.relational.core.conversion.AggregateChange;
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public class BeforeSaveEvent extends JdbcEventWithEntity {
|
||||
public class BeforeSaveEvent extends RelationalEventWithEntity {
|
||||
|
||||
private static final long serialVersionUID = -6996874391990315443L;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Optional;
|
||||
* @author Oliver Gierke
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface JdbcEvent {
|
||||
public interface RelationalEvent {
|
||||
|
||||
/**
|
||||
* The identifier of the aggregate root, triggering this event.
|
||||
@@ -20,16 +20,16 @@ import java.util.Optional;
|
||||
import org.springframework.data.relational.core.conversion.AggregateChange;
|
||||
|
||||
/**
|
||||
* A {@link SimpleJdbcEvent} which is guaranteed to have an entity.
|
||||
* A {@link SimpleRelationalEvent} which is guaranteed to have an entity.
|
||||
*
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public class JdbcEventWithEntity extends SimpleJdbcEvent implements WithEntity {
|
||||
public class RelationalEventWithEntity extends SimpleRelationalEvent implements WithEntity {
|
||||
|
||||
private static final long serialVersionUID = 4891455396602090638L;
|
||||
|
||||
JdbcEventWithEntity(Identifier id, Object entity, AggregateChange change) {
|
||||
RelationalEventWithEntity(Identifier id, Object entity, AggregateChange change) {
|
||||
super(id, Optional.of(entity), change);
|
||||
}
|
||||
}
|
||||
@@ -22,18 +22,18 @@ import org.springframework.data.relational.core.mapping.event.Identifier.Specifi
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A {@link SimpleJdbcEvent} guaranteed to have an identifier.
|
||||
* A {@link SimpleRelationalEvent} guaranteed to have an identifier.
|
||||
*
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public class JdbcEventWithId extends SimpleJdbcEvent implements WithId {
|
||||
public class RelationalEventWithId extends SimpleRelationalEvent implements WithId {
|
||||
|
||||
private static final long serialVersionUID = -8071323168471611098L;
|
||||
|
||||
private final Specified id;
|
||||
|
||||
public JdbcEventWithId(Specified id, Optional<Object> entity, @Nullable AggregateChange change) {
|
||||
public RelationalEventWithId(Specified id, Optional<Object> entity, @Nullable AggregateChange change) {
|
||||
|
||||
super(id, entity, change);
|
||||
|
||||
@@ -24,17 +24,17 @@ import org.springframework.data.relational.core.mapping.event.Identifier.Specifi
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A {@link SimpleJdbcEvent} which is guaranteed to have an identifier and an entity.
|
||||
* A {@link SimpleRelationalEvent} which is guaranteed to have an identifier and an entity.
|
||||
*
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
@Getter
|
||||
public class JdbcEventWithIdAndEntity extends JdbcEventWithId implements WithEntity {
|
||||
public class RelationalEventWithIdAndEntity extends RelationalEventWithId implements WithEntity {
|
||||
|
||||
private static final long serialVersionUID = -3194462549552515519L;
|
||||
|
||||
public JdbcEventWithIdAndEntity(Specified id, Object entity, @Nullable AggregateChange change) {
|
||||
public RelationalEventWithIdAndEntity(Specified id, Object entity, @Nullable AggregateChange change) {
|
||||
super(id, Optional.of(entity), change);
|
||||
}
|
||||
}
|
||||
@@ -29,14 +29,14 @@ import org.springframework.lang.Nullable;
|
||||
* @author Oliver Gierke
|
||||
* @since 1.0
|
||||
*/
|
||||
class SimpleJdbcEvent extends ApplicationEvent implements JdbcEvent {
|
||||
class SimpleRelationalEvent extends ApplicationEvent implements RelationalEvent {
|
||||
|
||||
private static final long serialVersionUID = -1798807778668751659L;
|
||||
|
||||
private final Object entity;
|
||||
private final AggregateChange change;
|
||||
|
||||
SimpleJdbcEvent(Identifier id, Optional<Object> entity, @Nullable AggregateChange change) {
|
||||
SimpleRelationalEvent(Identifier id, Optional<Object> entity, @Nullable AggregateChange change) {
|
||||
|
||||
super(id);
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
package org.springframework.data.relational.core.mapping.event;
|
||||
|
||||
/**
|
||||
* Interface for {@link SimpleJdbcEvent}s which are guaranteed to have an entity. Allows direct access to that entity,
|
||||
* Interface for {@link SimpleRelationalEvent}s which are guaranteed to have an entity. Allows direct access to that entity,
|
||||
* without going through an {@link java.util.Optional}
|
||||
*
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface WithEntity extends JdbcEvent {
|
||||
public interface WithEntity extends RelationalEvent {
|
||||
|
||||
/**
|
||||
* @return will never be {@literal null}.
|
||||
|
||||
@@ -18,13 +18,13 @@ package org.springframework.data.relational.core.mapping.event;
|
||||
import org.springframework.data.relational.core.mapping.event.Identifier.Specified;
|
||||
|
||||
/**
|
||||
* Interface for {@link SimpleJdbcEvent}s which are guaranteed to have a {@link Specified} identifier. Offers direct
|
||||
* Interface for {@link SimpleRelationalEvent}s which are guaranteed to have a {@link Specified} identifier. Offers direct
|
||||
* access to the {@link Specified} identifier.
|
||||
*
|
||||
* @author Jens Schauder
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface WithId extends JdbcEvent {
|
||||
public interface WithId extends RelationalEvent {
|
||||
|
||||
/**
|
||||
* Events with an identifier will always return a {@link Specified} one.
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.data.relational.core.mapping.event.BeforeSaveEvent;
|
||||
* @since 1.0
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class JdbcAuditingEventListener implements ApplicationListener<BeforeSaveEvent> {
|
||||
public class RelationalAuditingEventListener implements ApplicationListener<BeforeSaveEvent> {
|
||||
|
||||
private final IsNewAwareAuditingHandler handler;
|
||||
|
||||
Reference in New Issue
Block a user