Browse Source

#2 - Resolve package cycle between r2dbc.function and r2dbc.function.convert.

pull/1188/head
Mark Paluch 7 years ago
parent
commit
20eb2c1a6d
  1. 2
      src/main/java/org/springframework/data/r2dbc/function/DefaultDatabaseClient.java
  2. 1
      src/main/java/org/springframework/data/r2dbc/function/DefaultReactiveDataAccessStrategy.java
  3. 70
      src/main/java/org/springframework/data/r2dbc/function/ReactiveDataAccessStrategy.java
  4. 1
      src/main/java/org/springframework/data/r2dbc/function/convert/MappingR2dbcConverter.java
  5. 71
      src/main/java/org/springframework/data/r2dbc/function/convert/SettableValue.java
  6. 2
      src/main/java/org/springframework/data/r2dbc/repository/support/SimpleR2dbcRepository.java

2
src/main/java/org/springframework/data/r2dbc/function/DefaultDatabaseClient.java

@ -52,9 +52,9 @@ import org.springframework.data.domain.Sort; @@ -52,9 +52,9 @@ import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.NullHandling;
import org.springframework.data.domain.Sort.Order;
import org.springframework.data.r2dbc.UncategorizedR2dbcException;
import org.springframework.data.r2dbc.function.ReactiveDataAccessStrategy.SettableValue;
import org.springframework.data.r2dbc.function.connectionfactory.ConnectionProxy;
import org.springframework.data.r2dbc.function.convert.ColumnMapRowMapper;
import org.springframework.data.r2dbc.function.convert.SettableValue;
import org.springframework.data.r2dbc.support.R2dbcExceptionTranslator;
import org.springframework.jdbc.core.SqlProvider;
import org.springframework.lang.Nullable;

1
src/main/java/org/springframework/data/r2dbc/function/DefaultReactiveDataAccessStrategy.java

@ -28,6 +28,7 @@ import org.springframework.data.domain.Sort; @@ -28,6 +28,7 @@ import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Order;
import org.springframework.data.mapping.PersistentPropertyAccessor;
import org.springframework.data.r2dbc.function.convert.EntityRowMapper;
import org.springframework.data.r2dbc.function.convert.SettableValue;
import org.springframework.data.relational.core.conversion.BasicRelationalConverter;
import org.springframework.data.relational.core.conversion.RelationalConverter;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;

70
src/main/java/org/springframework/data/r2dbc/function/ReactiveDataAccessStrategy.java

@ -22,72 +22,40 @@ import java.util.List; @@ -22,72 +22,40 @@ import java.util.List;
import java.util.function.BiFunction;
import org.springframework.data.domain.Sort;
import org.springframework.lang.Nullable;
import org.springframework.data.r2dbc.function.convert.SettableValue;
/**
* @author Mark Paluch
*/
public interface ReactiveDataAccessStrategy {
/**
* @param typeToRead
* @return all field names for a specific type.
*/
List<String> getAllFields(Class<?> typeToRead);
/**
* @param object
* @return {@link SettableValue} that represent an {@code INSERT} of {@code object}.
*/
List<SettableValue> getInsert(Object object);
/**
* Map the {@link Sort} object to apply field name mapping using {@link Class the type to read}.
*
* @param typeToRead
* @param sort
* @return
*/
Sort getMappedSort(Class<?> typeToRead, Sort sort);
// TODO: Broaden T to Mono<T>/Flux<T> for reactive relational data access?
<T> BiFunction<Row, RowMetadata, T> getRowMapper(Class<T> typeToRead);
String getTableName(Class<?> type);
/**
* A database value that can be set in a statement.
* @param type
* @return the table name for the {@link Class entity type}.
*/
class SettableValue {
private final Object identifier;
private final @Nullable Object value;
private final Class<?> type;
/**
* Create a {@link SettableValue} using an integer index.
*
* @param index
* @param value
* @param type
*/
public SettableValue(int index, @Nullable Object value, Class<?> type) {
this.identifier = index;
this.value = value;
this.type = type;
}
/**
* Create a {@link SettableValue} using a {@link String} identifier.
*
* @param identifier
* @param value
* @param type
*/
public SettableValue(String identifier, @Nullable Object value, Class<?> type) {
this.identifier = identifier;
this.value = value;
this.type = type;
}
public Object getIdentifier() {
return identifier;
}
@Nullable
public Object getValue() {
return value;
}
public Class<?> getType() {
return type;
}
}
String getTableName(Class<?> type);
}

1
src/main/java/org/springframework/data/r2dbc/function/convert/MappingR2dbcConverter.java

@ -26,7 +26,6 @@ import java.util.function.BiFunction; @@ -26,7 +26,6 @@ import java.util.function.BiFunction;
import org.springframework.core.convert.ConversionService;
import org.springframework.data.mapping.PersistentPropertyAccessor;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.r2dbc.function.ReactiveDataAccessStrategy.SettableValue;
import org.springframework.data.relational.core.conversion.RelationalConverter;
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;

71
src/main/java/org/springframework/data/r2dbc/function/convert/SettableValue.java

@ -0,0 +1,71 @@ @@ -0,0 +1,71 @@
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.r2dbc.function.convert;
import org.springframework.lang.Nullable;
/**
* A database value that can be set in a statement.
*
* @author Mark Paluch
*/
public class SettableValue {
private final Object identifier;
private final @Nullable Object value;
private final Class<?> type;
/**
* Create a {@link SettableValue} using an integer index.
*
* @param index
* @param value
* @param type
*/
public SettableValue(int index, @Nullable Object value, Class<?> type) {
this.identifier = index;
this.value = value;
this.type = type;
}
/**
* Create a {@link SettableValue} using a {@link String} identifier.
*
* @param identifier
* @param value
* @param type
*/
public SettableValue(String identifier, @Nullable Object value, Class<?> type) {
this.identifier = identifier;
this.value = value;
this.type = type;
}
public Object getIdentifier() {
return identifier;
}
@Nullable
public Object getValue() {
return value;
}
public Class<?> getType() {
return type;
}
}

2
src/main/java/org/springframework/data/r2dbc/repository/support/SimpleR2dbcRepository.java

@ -30,8 +30,8 @@ import org.springframework.data.r2dbc.function.DatabaseClient; @@ -30,8 +30,8 @@ import org.springframework.data.r2dbc.function.DatabaseClient;
import org.springframework.data.r2dbc.function.DatabaseClient.BindSpec;
import org.springframework.data.r2dbc.function.DatabaseClient.GenericExecuteSpec;
import org.springframework.data.r2dbc.function.FetchSpec;
import org.springframework.data.r2dbc.function.ReactiveDataAccessStrategy.SettableValue;
import org.springframework.data.r2dbc.function.convert.MappingR2dbcConverter;
import org.springframework.data.r2dbc.function.convert.SettableValue;
import org.springframework.data.relational.repository.query.RelationalEntityInformation;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.util.Assert;

Loading…
Cancel
Save