DATAJDBC-544 - Removes all Lombok from production code.
This commit is contained in:
@@ -15,16 +15,17 @@
|
||||
*/
|
||||
package org.springframework.data.jdbc.core.convert;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
/**
|
||||
* A collection of utility methods for dealing with arrays.
|
||||
*
|
||||
* @author Jens Schauder
|
||||
* @since 1.1
|
||||
*/
|
||||
@UtilityClass
|
||||
class ArrayUtil {
|
||||
final class ArrayUtil {
|
||||
|
||||
private ArrayUtil() {
|
||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an {@code Byte[]} into a {@code byte[]}.
|
||||
|
||||
@@ -15,21 +15,57 @@
|
||||
*/
|
||||
package org.springframework.data.jdbc.core.convert;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import java.sql.JDBCType;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Wraps a value with the JDBCType that should be used to pass it as a bind parameter to a
|
||||
* {@link java.sql.PreparedStatement}. Register a converter from any type to {@link JdbcValue} in order to control
|
||||
* the value and the {@link JDBCType} as which a value should get passed to the JDBC driver.
|
||||
* {@link java.sql.PreparedStatement}. Register a converter from any type to {@link JdbcValue} in order to control the
|
||||
* value and the {@link JDBCType} as which a value should get passed to the JDBC driver.
|
||||
*
|
||||
* @author Jens Schauder
|
||||
* @since 1.1
|
||||
*/
|
||||
@Value(staticConstructor = "of")
|
||||
public class JdbcValue {
|
||||
public final class JdbcValue {
|
||||
|
||||
Object value;
|
||||
JDBCType jdbcType;
|
||||
private final Object value;
|
||||
private final JDBCType jdbcType;
|
||||
|
||||
private JdbcValue(@Nullable Object value, @Nullable JDBCType jdbcType) {
|
||||
|
||||
this.value = value;
|
||||
this.jdbcType = jdbcType;
|
||||
}
|
||||
|
||||
public static JdbcValue of(@Nullable Object value, @Nullable JDBCType jdbcType) {
|
||||
return new JdbcValue(value, jdbcType);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JDBCType getJdbcType() {
|
||||
return this.jdbcType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
JdbcValue jdbcValue = (JdbcValue) o;
|
||||
return Objects.equals(value, jdbcValue.value) && jdbcType == jdbcValue.jdbcType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(value, jdbcType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.jdbc.core.convert;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
@@ -26,7 +24,6 @@ import org.springframework.data.relational.core.mapping.PersistentPropertyPathEx
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing;
|
||||
import org.springframework.data.relational.core.sql.SqlIdentifier;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
/**
|
||||
* A {@link RowMapper} that maps a row to a {@link Map.Entry} so an {@link Iterable} of those can be converted to a
|
||||
@@ -35,7 +32,6 @@ import org.springframework.lang.NonNull;
|
||||
*
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
class MapEntityRowMapper<T> implements RowMapper<Map.Entry<Object, T>> {
|
||||
|
||||
private final PersistentPropertyPathExtension path;
|
||||
@@ -44,7 +40,16 @@ class MapEntityRowMapper<T> implements RowMapper<Map.Entry<Object, T>> {
|
||||
private final SqlIdentifier keyColumn;
|
||||
private final IdentifierProcessing identifierProcessing;
|
||||
|
||||
@NonNull
|
||||
MapEntityRowMapper(PersistentPropertyPathExtension path, JdbcConverter converter, Identifier identifier,
|
||||
SqlIdentifier keyColumn, IdentifierProcessing identifierProcessing) {
|
||||
|
||||
this.path = path;
|
||||
this.converter = converter;
|
||||
this.identifier = identifier;
|
||||
this.keyColumn = keyColumn;
|
||||
this.identifierProcessing = identifierProcessing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map.Entry<Object, T> mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
|
||||
|
||||
@@ -15,13 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.jdbc.core.convert;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jdbc.repository.support.SimpleJdbcRepository;
|
||||
@@ -41,6 +34,11 @@ import org.springframework.data.util.Lazy;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Generates SQL statements to be used by {@link SimpleJdbcRepository}
|
||||
*
|
||||
@@ -722,11 +720,60 @@ class SqlGenerator {
|
||||
/**
|
||||
* Value object representing a {@code JOIN} association.
|
||||
*/
|
||||
@Value
|
||||
static class Join {
|
||||
Table joinTable;
|
||||
Column joinColumn;
|
||||
Column parentId;
|
||||
static final class Join {
|
||||
|
||||
private final Table joinTable;
|
||||
private final Column joinColumn;
|
||||
private final Column parentId;
|
||||
|
||||
Join(Table joinTable, Column joinColumn, Column parentId) {
|
||||
|
||||
Assert.notNull( joinTable,"JoinTable must not be null.");
|
||||
Assert.notNull( joinColumn,"JoinColumn must not be null.");
|
||||
Assert.notNull( parentId,"ParentId must not be null.");
|
||||
|
||||
this.joinTable = joinTable;
|
||||
this.joinColumn = joinColumn;
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
Table getJoinTable() {
|
||||
return this.joinTable;
|
||||
}
|
||||
|
||||
Column getJoinColumn() {
|
||||
return this.joinColumn;
|
||||
}
|
||||
|
||||
Column getParentId() {
|
||||
return this.parentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Join join = (Join) o;
|
||||
return joinTable.equals(join.joinTable) &&
|
||||
joinColumn.equals(join.joinColumn) &&
|
||||
parentId.equals(join.parentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(joinTable, joinColumn, parentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return "Join{" +
|
||||
"joinTable=" + joinTable +
|
||||
", joinColumn=" + joinColumn +
|
||||
", parentId=" + parentId +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,12 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.jdbc.core.convert;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.relational.core.dialect.Dialect;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
|
||||
/**
|
||||
@@ -31,7 +30,6 @@ import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
* @author Mark Paluch
|
||||
* @author Milan Milanov
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class SqlGeneratorSource {
|
||||
|
||||
private final Map<Class<?>, SqlGenerator> CACHE = new ConcurrentReferenceHashMap<>();
|
||||
@@ -39,6 +37,17 @@ public class SqlGeneratorSource {
|
||||
private final JdbcConverter converter;
|
||||
private final Dialect dialect;
|
||||
|
||||
public SqlGeneratorSource(RelationalMappingContext context, JdbcConverter converter, Dialect dialect) {
|
||||
|
||||
Assert.notNull(context, "Context must not be null.");
|
||||
Assert.notNull(converter, "Converter must not be null.");
|
||||
Assert.notNull(dialect, "Dialect must not be null.");
|
||||
|
||||
this.context = context;
|
||||
this.converter = converter;
|
||||
this.dialect = dialect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the {@link Dialect} used by the created {@link SqlGenerator} instances. Guaranteed to be not
|
||||
* {@literal null}.
|
||||
|
||||
@@ -15,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.jdbc.core.mapping;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A reference to the aggregate root of a different aggregate.
|
||||
@@ -49,16 +48,42 @@ public interface AggregateReference<T, ID> {
|
||||
* @param <T>
|
||||
* @param <ID>
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
class IdOnlyAggregateReference<T, ID> implements AggregateReference<T, ID> {
|
||||
|
||||
private final ID id;
|
||||
|
||||
public IdOnlyAggregateReference(ID id) {
|
||||
|
||||
Assert.notNull(id, "Id must not be null.");
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
IdOnlyAggregateReference<?, ?> that = (IdOnlyAggregateReference<?, ?>) o;
|
||||
return id.equals(that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return "IdOnlyAggregateReference{" + "id=" + id + '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.jdbc.repository.query;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -312,10 +311,55 @@ class JdbcQueryCreator extends RelationalQueryCreator<ParametrizedQuery> {
|
||||
/**
|
||||
* Value object representing a {@code JOIN} association.
|
||||
*/
|
||||
@Value
|
||||
static private class Join {
|
||||
Table joinTable;
|
||||
Column joinColumn;
|
||||
Column parentId;
|
||||
static private final class Join {
|
||||
|
||||
private final Table joinTable;
|
||||
private final Column joinColumn;
|
||||
private final Column parentId;
|
||||
|
||||
Join(Table joinTable, Column joinColumn, Column parentId) {
|
||||
|
||||
Assert.notNull(joinTable, "JoinTable must not be null.");
|
||||
Assert.notNull(joinColumn, "JoinColumn must not be null.");
|
||||
Assert.notNull(parentId, "ParentId must not be null.");
|
||||
|
||||
this.joinTable = joinTable;
|
||||
this.joinColumn = joinColumn;
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
Table getJoinTable() {
|
||||
return this.joinTable;
|
||||
}
|
||||
|
||||
Column getJoinColumn() {
|
||||
return this.joinColumn;
|
||||
}
|
||||
|
||||
Column getParentId() {
|
||||
return this.parentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
Join join = (Join) o;
|
||||
return joinTable.equals(join.joinTable) && joinColumn.equals(join.joinColumn) && parentId.equals(join.parentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(joinTable, joinColumn, parentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return "Join{" + "joinTable=" + joinTable + ", joinColumn=" + joinColumn + ", parentId=" + parentId + '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,21 +15,18 @@
|
||||
*/
|
||||
package org.springframework.data.jdbc.repository.support;
|
||||
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jdbc.core.JdbcAggregateOperations;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.util.Streamable;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Default implementation of the {@link org.springframework.data.repository.CrudRepository} interface.
|
||||
@@ -38,12 +35,20 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Oliver Gierke
|
||||
* @author Milan Milanov
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Transactional(readOnly = true)
|
||||
public class SimpleJdbcRepository<T, ID> implements PagingAndSortingRepository<T, ID> {
|
||||
|
||||
private final @NonNull JdbcAggregateOperations entityOperations;
|
||||
private final @NonNull PersistentEntity<T, ?> entity;
|
||||
private final JdbcAggregateOperations entityOperations;
|
||||
private final PersistentEntity<T, ?> entity;
|
||||
|
||||
public SimpleJdbcRepository(JdbcAggregateOperations entityOperations,PersistentEntity<T, ?> entity) {
|
||||
|
||||
Assert.notNull(entityOperations, "EntityOperations must not be null.");
|
||||
Assert.notNull(entity, "Entity must not be null.");
|
||||
|
||||
this.entityOperations = entityOperations;
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.jdbc.support;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.sql.Date;
|
||||
@@ -37,8 +35,7 @@ import org.springframework.util.Assert;
|
||||
* @author Jens Schauder
|
||||
* @author Thomas Lang
|
||||
*/
|
||||
@UtilityClass
|
||||
public class JdbcUtil {
|
||||
public final class JdbcUtil {
|
||||
|
||||
private static final Map<Class<?>, Integer> sqlTypeMappings = new HashMap<>();
|
||||
|
||||
@@ -67,6 +64,10 @@ public class JdbcUtil {
|
||||
sqlTypeMappings.put(Timestamp.class, Types.TIMESTAMP);
|
||||
}
|
||||
|
||||
private JdbcUtil() {
|
||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Types} value suitable for passing a value of the provided type to a
|
||||
* {@link java.sql.PreparedStatement}.
|
||||
|
||||
@@ -15,20 +15,16 @@
|
||||
*/
|
||||
package org.springframework.data.jdbc.core.convert;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.data.relational.core.sql.SqlIdentifier;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@@ -41,8 +37,6 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Mark Paluch
|
||||
* @since 1.1
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public final class Identifier {
|
||||
|
||||
private static final Identifier EMPTY = new Identifier(Collections.emptyList());
|
||||
@@ -185,13 +179,55 @@ public final class Identifier {
|
||||
*
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
@Value
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
static class SingleIdentifierValue {
|
||||
static final class SingleIdentifierValue {
|
||||
|
||||
SqlIdentifier name;
|
||||
Object value;
|
||||
Class<?> targetType;
|
||||
private final SqlIdentifier name;
|
||||
private final Object value;
|
||||
private final Class<?> targetType;
|
||||
|
||||
private SingleIdentifierValue(SqlIdentifier name, @Nullable Object value, Class<?> targetType) {
|
||||
|
||||
Assert.notNull(name, "Name must not be null.");
|
||||
Assert.notNull(targetType, "TargetType must not be null.");
|
||||
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.targetType = targetType;
|
||||
}
|
||||
|
||||
public SqlIdentifier getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public Class<?> getTargetType() {
|
||||
return this.targetType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
SingleIdentifierValue that = (SingleIdentifierValue) o;
|
||||
return name.equals(that.name) && value.equals(that.value) && targetType.equals(that.targetType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, value, targetType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return "SingleIdentifierValue{" + "name=" + name + ", value=" + value + ", targetType=" + targetType + '}';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,7 +249,7 @@ public final class Identifier {
|
||||
void accept(SqlIdentifier name, Object value, Class<?> targetType);
|
||||
}
|
||||
|
||||
private static class StringKeyedLinkedHashMap<V> extends LinkedHashMap<SqlIdentifier,V> {
|
||||
private static class StringKeyedLinkedHashMap<V> extends LinkedHashMap<SqlIdentifier, V> {
|
||||
|
||||
public StringKeyedLinkedHashMap(int initialCapacity) {
|
||||
super(initialCapacity);
|
||||
@@ -234,4 +270,24 @@ public final class Identifier {
|
||||
return super.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Identifier that = (Identifier) o;
|
||||
return Objects.equals(parts, that.parts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(parts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return "Identifier{" + "parts=" + parts + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.relational.core.conversion;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.support.ConfigurableConversionService;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
@@ -43,6 +37,10 @@ import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* {@link RelationalConverter} that uses a {@link MappingContext} to apply basic conversion of relational values to
|
||||
* property values.
|
||||
@@ -249,11 +247,17 @@ public class BasicRelationalConverter implements RelationalConverter {
|
||||
* @param <P>
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
class ConvertingParameterValueProvider<P extends PersistentProperty<P>> implements ParameterValueProvider<P> {
|
||||
|
||||
private final Function<Parameter<?, P>, Object> delegate;
|
||||
|
||||
ConvertingParameterValueProvider(Function<Parameter<?, P>, Object> delegate) {
|
||||
|
||||
Assert.notNull(delegate, "Delegate must not be null.");
|
||||
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mapping.model.ParameterValueProvider#getParameterValue(org.springframework.data.mapping.PreferredConstructor.Parameter)
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.relational.core.conversion;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import org.springframework.data.mapping.PersistentPropertyPath;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
|
||||
import org.springframework.data.util.Pair;
|
||||
@@ -28,34 +26,58 @@ import org.springframework.lang.Nullable;
|
||||
*
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
@Value
|
||||
class PathNode {
|
||||
final class PathNode {
|
||||
|
||||
/**
|
||||
* The path to this entity
|
||||
*/
|
||||
PersistentPropertyPath<RelationalPersistentProperty> path;
|
||||
private final PersistentPropertyPath<RelationalPersistentProperty> path;
|
||||
|
||||
/**
|
||||
* The parent {@link PathNode}. This is {@code null} if this is the root entity.
|
||||
*/
|
||||
@Nullable PathNode parent;
|
||||
@Nullable private final PathNode parent;
|
||||
|
||||
/**
|
||||
* The value of the entity.
|
||||
*/
|
||||
Object value;
|
||||
private final Object value;
|
||||
|
||||
PathNode(PersistentPropertyPath<RelationalPersistentProperty> path, @Nullable PathNode parent, Object value) {
|
||||
|
||||
this.path = path;
|
||||
this.parent = parent;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the node represents a qualified property (i.e. a {@link java.util.List} or {@link java.util.Map}) the actual
|
||||
* value is an element of the {@literal List} or a value of the {@literal Map}, while the {@link #value} is actually a
|
||||
* {@link Pair} with the index or key as the first element and the actual value as second element.
|
||||
*
|
||||
*/
|
||||
Object getActualValue() {
|
||||
|
||||
return getPath().getRequiredLeafProperty().isQualified() //
|
||||
? ((Pair) getValue()).getSecond() //
|
||||
? ((Pair<?,?>) getValue()).getSecond() //
|
||||
: getValue();
|
||||
}
|
||||
|
||||
public PersistentPropertyPath<RelationalPersistentProperty> getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PathNode getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return "PathNode{" + "path=" + path + ", parent=" + parent + ", value=" + value + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.relational.core.dialect;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.OptionalLong;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -74,8 +72,7 @@ public abstract class AbstractDialect implements Dialect {
|
||||
Function<Select, ? extends CharSequence> afterOrderByLimit = getAfterOrderByLimit();
|
||||
Function<Select, ? extends CharSequence> afterOrderByLock = getAfterOrderByLock();
|
||||
|
||||
return select -> String.valueOf(afterOrderByLimit.apply(select)) +
|
||||
afterOrderByLock.apply(select);
|
||||
return select -> String.valueOf(afterOrderByLimit.apply(select)) + afterOrderByLock.apply(select);
|
||||
}
|
||||
|
||||
private Function<Select, ? extends CharSequence> getAfterOrderByLimit() {
|
||||
@@ -109,8 +106,7 @@ public abstract class AbstractDialect implements Dialect {
|
||||
private final Function<Select, ? extends CharSequence> afterFromTable;
|
||||
private final Function<Select, ? extends CharSequence> afterOrderBy;
|
||||
|
||||
DialectSelectRenderContext(
|
||||
Function<Select, ? extends CharSequence> afterFromTable,
|
||||
DialectSelectRenderContext(Function<Select, ? extends CharSequence> afterFromTable,
|
||||
Function<Select, ? extends CharSequence> afterOrderBy) {
|
||||
|
||||
this.afterFromTable = afterFromTable;
|
||||
@@ -139,11 +135,14 @@ public abstract class AbstractDialect implements Dialect {
|
||||
/**
|
||||
* After {@code ORDER BY} function rendering the {@link LimitClause}.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
static class AfterOrderByLimitRenderFunction implements Function<Select, CharSequence> {
|
||||
|
||||
private final LimitClause clause;
|
||||
|
||||
public AfterOrderByLimitRenderFunction(LimitClause clause) {
|
||||
this.clause = clause;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.util.function.Function#apply(java.lang.Object)
|
||||
@@ -173,11 +172,14 @@ public abstract class AbstractDialect implements Dialect {
|
||||
/**
|
||||
* {@code LOCK} function rendering the {@link LockClause}.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
static class LockRenderFunction implements Function<Select, CharSequence> {
|
||||
|
||||
private final LockClause clause;
|
||||
|
||||
public LockRenderFunction(LockClause clause) {
|
||||
this.clause = clause;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.util.function.Function#apply(java.lang.Object)
|
||||
@@ -198,7 +200,6 @@ public abstract class AbstractDialect implements Dialect {
|
||||
/**
|
||||
* Prepends a non-empty rendering result with a leading whitespace,
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
enum PrependWithLeadingWhitespace implements Function<CharSequence, CharSequence> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.relational.core.dialect;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing;
|
||||
import org.springframework.data.relational.core.sql.LockOptions;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -127,7 +125,6 @@ public class AnsiDialect extends AbstractDialect {
|
||||
return ARRAY_COLUMNS;
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
static class AnsiArrayColumns implements ArrayColumns {
|
||||
|
||||
/*
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.relational.core.dialect;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing;
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing.LetterCasing;
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing.Quoting;
|
||||
@@ -107,7 +105,6 @@ public class H2Dialect extends AbstractDialect {
|
||||
return ARRAY_COLUMNS;
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
static class H2ArrayColumns implements ArrayColumns {
|
||||
|
||||
/*
|
||||
|
||||
@@ -15,19 +15,16 @@
|
||||
*/
|
||||
package org.springframework.data.relational.core.dialect;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.relational.core.sql.From;
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing;
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing.LetterCasing;
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing.Quoting;
|
||||
import org.springframework.data.relational.core.sql.LockOptions;
|
||||
import org.springframework.data.relational.core.sql.Table;
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing.LetterCasing;
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing.Quoting;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An SQL dialect for Postgres.
|
||||
*
|
||||
@@ -159,7 +156,6 @@ public class PostgresDialect extends AbstractDialect {
|
||||
}
|
||||
};
|
||||
|
||||
@RequiredArgsConstructor
|
||||
static class PostgresArrayColumns implements ArrayColumns {
|
||||
|
||||
/*
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.relational.core.dialect;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing;
|
||||
import org.springframework.data.relational.core.sql.render.NamingStrategies;
|
||||
import org.springframework.data.relational.core.sql.render.RenderContext;
|
||||
@@ -75,15 +73,23 @@ public class RenderContextFactory {
|
||||
/**
|
||||
* {@link RenderContext} derived from {@link Dialect} specifics.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
static class DialectRenderContext implements RenderContext {
|
||||
|
||||
private final RenderNamingStrategy renderNamingStrategy;
|
||||
|
||||
private final IdentifierProcessing identifierProcessing;
|
||||
|
||||
private final SelectRenderContext selectRenderContext;
|
||||
|
||||
DialectRenderContext(RenderNamingStrategy renderNamingStrategy, IdentifierProcessing identifierProcessing, SelectRenderContext selectRenderContext) {
|
||||
|
||||
Assert.notNull(renderNamingStrategy, "RenderNamingStrategy must not be null");
|
||||
Assert.notNull(identifierProcessing, "IdentifierProcessing must not be null");
|
||||
Assert.notNull(selectRenderContext, "SelectRenderContext must not be null");
|
||||
|
||||
this.renderNamingStrategy = renderNamingStrategy;
|
||||
this.identifierProcessing = identifierProcessing;
|
||||
this.selectRenderContext = selectRenderContext;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.relational.core.sql.render.RenderContext#getNamingStrategy()
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.relational.core.mapping;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.mapping.PersistentPropertyPath;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
@@ -26,6 +24,8 @@ import org.springframework.data.util.Lazy;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A wrapper around a {@link org.springframework.data.mapping.PersistentPropertyPath} for making common operations
|
||||
* available used in SQL generation and conversion
|
||||
@@ -33,7 +33,6 @@ import org.springframework.util.Assert;
|
||||
* @author Jens Schauder
|
||||
* @since 1.1
|
||||
*/
|
||||
@EqualsAndHashCode(exclude = { "columnAlias", "context" })
|
||||
public class PersistentPropertyPathExtension {
|
||||
|
||||
private final RelationalPersistentEntity<?> entity;
|
||||
@@ -436,4 +435,18 @@ public class PersistentPropertyPathExtension {
|
||||
: columnName.transform(name -> tableAlias.getReference(IdentifierProcessing.NONE) + "_" + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PersistentPropertyPathExtension that = (PersistentPropertyPathExtension) o;
|
||||
return entity.equals(that.entity) &&
|
||||
path.equals(that.path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(entity, path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.relational.core.mapping;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import org.springframework.data.mapping.context.AbstractMappingContext;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.data.mapping.model.Property;
|
||||
@@ -36,7 +34,7 @@ import org.springframework.util.Assert;
|
||||
public class RelationalMappingContext
|
||||
extends AbstractMappingContext<RelationalPersistentEntity<?>, RelationalPersistentProperty> {
|
||||
|
||||
@Getter private final NamingStrategy namingStrategy;
|
||||
private final NamingStrategy namingStrategy;
|
||||
private boolean forceQuote = true;
|
||||
|
||||
/**
|
||||
@@ -107,4 +105,8 @@ public class RelationalMappingContext
|
||||
|
||||
return persistentProperty;
|
||||
}
|
||||
|
||||
public NamingStrategy getNamingStrategy() {
|
||||
return this.namingStrategy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.relational.core.mapping.event;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.data.auditing.IsNewAwareAuditingHandler;
|
||||
import org.springframework.data.relational.core.mapping.event.BeforeConvertCallback;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* {@link BeforeConvertCallback} to capture auditing information on persisting and updating entities.
|
||||
@@ -31,7 +29,6 @@ import org.springframework.data.relational.core.mapping.event.BeforeConvertCallb
|
||||
* @author Mark Paluch
|
||||
* @since 1.1
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class RelationalAuditingCallback implements BeforeConvertCallback<Object>, Ordered {
|
||||
|
||||
/**
|
||||
@@ -45,6 +42,13 @@ public class RelationalAuditingCallback implements BeforeConvertCallback<Object>
|
||||
|
||||
private final IsNewAwareAuditingHandler handler;
|
||||
|
||||
public RelationalAuditingCallback(IsNewAwareAuditingHandler handler) {
|
||||
|
||||
Assert.notNull(handler, "Handler must not be null;");
|
||||
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.core.Ordered#getOrder()
|
||||
|
||||
@@ -15,16 +15,14 @@
|
||||
*/
|
||||
package org.springframework.data.relational.core.sql.render;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.data.relational.core.sql.Column;
|
||||
import org.springframework.data.relational.core.sql.SqlIdentifier;
|
||||
import org.springframework.data.relational.core.sql.Table;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Factory for {@link RenderNamingStrategy} objects.
|
||||
*
|
||||
@@ -115,12 +113,17 @@ public abstract class NamingStrategies {
|
||||
INSTANCE;
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
static class DelegatingRenderNamingStrategy implements RenderNamingStrategy {
|
||||
|
||||
private final RenderNamingStrategy delegate;
|
||||
private final Function<String, String> mappingFunction;
|
||||
|
||||
DelegatingRenderNamingStrategy(RenderNamingStrategy delegate, Function<String, String> mappingFunction) {
|
||||
|
||||
this.delegate = delegate;
|
||||
this.mappingFunction = mappingFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlIdentifier getName(Column column) {
|
||||
return delegate.getName(column).transform(mappingFunction::apply);
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.relational.core.sql.render;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing;
|
||||
|
||||
/**
|
||||
@@ -25,11 +23,14 @@ import org.springframework.data.relational.core.sql.IdentifierProcessing;
|
||||
* @author Mark Paluch
|
||||
* @since 1.1
|
||||
*/
|
||||
@Value
|
||||
class SimpleRenderContext implements RenderContext {
|
||||
final class SimpleRenderContext implements RenderContext {
|
||||
|
||||
private final RenderNamingStrategy namingStrategy;
|
||||
|
||||
SimpleRenderContext(RenderNamingStrategy namingStrategy) {
|
||||
this.namingStrategy = namingStrategy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdentifierProcessing getIdentifierProcessing() {
|
||||
return IdentifierProcessing.NONE;
|
||||
@@ -40,6 +41,18 @@ class SimpleRenderContext implements RenderContext {
|
||||
return DefaultSelectRenderContext.INSTANCE;
|
||||
}
|
||||
|
||||
public RenderNamingStrategy getNamingStrategy() {
|
||||
return this.namingStrategy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return "SimpleRenderContext{" +
|
||||
"namingStrategy=" + namingStrategy +
|
||||
'}';
|
||||
}
|
||||
|
||||
enum DefaultSelectRenderContext implements SelectRenderContext {
|
||||
INSTANCE;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.relational.repository.query;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
|
||||
import org.springframework.data.relational.core.sql.SqlIdentifier;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -29,7 +27,7 @@ import org.springframework.util.Assert;
|
||||
public class SimpleRelationalEntityMetadata<T> implements RelationalEntityMetadata<T> {
|
||||
|
||||
private final Class<T> type;
|
||||
private final @Getter RelationalPersistentEntity<?> tableEntity;
|
||||
private final RelationalPersistentEntity<?> tableEntity;
|
||||
|
||||
/**
|
||||
* Creates a new {@link SimpleRelationalEntityMetadata} using the given type and {@link RelationalPersistentEntity} to
|
||||
@@ -60,4 +58,8 @@ public class SimpleRelationalEntityMetadata<T> implements RelationalEntityMetada
|
||||
public SqlIdentifier getTableName() {
|
||||
return tableEntity.getTableName();
|
||||
}
|
||||
|
||||
public RelationalPersistentEntity<?> getTableEntity() {
|
||||
return this.tableEntity;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user