#2 - Create relational and r2dbc packages.

Move types into relational and r2dbc packages in preparation for a later module separation.
This commit is contained in:
Mark Paluch
2018-06-21 08:44:03 +02:00
parent cee7479cd0
commit 8b006abbe5
43 changed files with 212 additions and 158 deletions

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function;
package org.springframework.data.r2dbc.function;
import io.r2dbc.spi.Connection;
import reactor.core.publisher.Flux;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function;
package org.springframework.data.r2dbc.function;
import io.r2dbc.spi.ConnectionFactory;
import io.r2dbc.spi.Row;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function;
package org.springframework.data.r2dbc.function;
import io.r2dbc.spi.Connection;
import io.r2dbc.spi.ConnectionFactory;
@@ -53,7 +53,8 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.NullHandling;
import org.springframework.data.domain.Sort.Order;
import org.springframework.data.jdbc.core.function.connectionfactory.ConnectionProxy;
import org.springframework.data.r2dbc.function.connectionfactory.ConnectionProxy;
import org.springframework.data.r2dbc.function.convert.ColumnMapRowMapper;
import org.springframework.data.util.Pair;
import org.springframework.jdbc.core.SqlProvider;
import org.springframework.jdbc.support.SQLExceptionTranslator;
@@ -240,7 +241,7 @@ class DefaultDatabaseClient implements DatabaseClient, ConnectionAccessor {
}
/**
* Default {@link org.springframework.data.jdbc.core.function.DatabaseClient.SqlSpec} implementation.
* Default {@link DatabaseClient.SqlSpec} implementation.
*/
private class DefaultSqlSpec implements SqlSpec {
@@ -261,8 +262,7 @@ class DefaultDatabaseClient implements DatabaseClient, ConnectionAccessor {
}
/**
* Base class for {@link org.springframework.data.jdbc.core.function.DatabaseClient.GenericExecuteSpec}
* implementations.
* Base class for {@link DatabaseClient.GenericExecuteSpec} implementations.
*/
@RequiredArgsConstructor
private class GenericExecuteSpecSupport {
@@ -358,7 +358,7 @@ class DefaultDatabaseClient implements DatabaseClient, ConnectionAccessor {
}
/**
* Default {@link org.springframework.data.jdbc.core.function.DatabaseClient.GenericExecuteSpec} implementation.
* Default {@link DatabaseClient.GenericExecuteSpec} implementation.
*/
private class DefaultGenericExecuteSpec extends GenericExecuteSpecSupport implements GenericExecuteSpec {
@@ -422,7 +422,7 @@ class DefaultDatabaseClient implements DatabaseClient, ConnectionAccessor {
}
/**
* Default {@link org.springframework.data.jdbc.core.function.DatabaseClient.GenericExecuteSpec} implementation.
* Default {@link DatabaseClient.GenericExecuteSpec} implementation.
*/
@SuppressWarnings("unchecked")
private class DefaultTypedGenericExecuteSpec<T> extends GenericExecuteSpecSupport implements TypedExecuteSpec<T> {
@@ -490,7 +490,7 @@ class DefaultDatabaseClient implements DatabaseClient, ConnectionAccessor {
}
/**
* Default {@link org.springframework.data.jdbc.core.function.DatabaseClient.SelectFromSpec} implementation.
* Default {@link DatabaseClient.SelectFromSpec} implementation.
*/
class DefaultSelectFromSpec implements SelectFromSpec {
@@ -506,8 +506,7 @@ class DefaultDatabaseClient implements DatabaseClient, ConnectionAccessor {
}
/**
* Base class for {@link org.springframework.data.jdbc.core.function.DatabaseClient.GenericExecuteSpec}
* implementations.
* Base class for {@link DatabaseClient.GenericExecuteSpec} implementations.
*/
@RequiredArgsConstructor
private abstract class DefaultSelectSpecSupport {
@@ -678,7 +677,7 @@ class DefaultDatabaseClient implements DatabaseClient, ConnectionAccessor {
}
/**
* Default implementation of {@link org.springframework.data.jdbc.core.function.DatabaseClient.TypedInsertSpec}.
* Default implementation of {@link DatabaseClient.TypedInsertSpec}.
*/
@SuppressWarnings("unchecked")
private class DefaultTypedSelectSpec<T> extends DefaultSelectSpecSupport implements TypedSelectSpec<T> {
@@ -779,7 +778,7 @@ class DefaultDatabaseClient implements DatabaseClient, ConnectionAccessor {
}
/**
* Default {@link org.springframework.data.jdbc.core.function.DatabaseClient.InsertIntoSpec} implementation.
* Default {@link DatabaseClient.InsertIntoSpec} implementation.
*/
class DefaultInsertIntoSpec implements InsertIntoSpec {
@@ -795,7 +794,7 @@ class DefaultDatabaseClient implements DatabaseClient, ConnectionAccessor {
}
/**
* Default implementation of {@link org.springframework.data.jdbc.core.function.DatabaseClient.GenericInsertSpec}.
* Default implementation of {@link DatabaseClient.GenericInsertSpec}.
*/
@RequiredArgsConstructor
class DefaultGenericInsertSpec implements GenericInsertSpec {
@@ -891,7 +890,7 @@ class DefaultDatabaseClient implements DatabaseClient, ConnectionAccessor {
}
/**
* Default implementation of {@link org.springframework.data.jdbc.core.function.DatabaseClient.TypedInsertSpec}.
* Default implementation of {@link DatabaseClient.TypedInsertSpec}.
*/
@RequiredArgsConstructor
class DefaultTypedInsertSpec<T> implements TypedInsertSpec<T>, InsertSpec {

View File

@@ -14,18 +14,18 @@
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function;
package org.springframework.data.r2dbc.function;
import io.r2dbc.spi.ConnectionFactory;
import java.util.function.Consumer;
import org.springframework.data.jdbc.core.function.DatabaseClient.Builder;
import org.springframework.data.r2dbc.function.DatabaseClient.Builder;
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator;
import org.springframework.jdbc.support.SQLExceptionTranslator;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import io.r2dbc.spi.ConnectionFactory;
/**
* Default implementation of {@link DatabaseClient.Builder}.
*

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function;
package org.springframework.data.r2dbc.function;
import io.r2dbc.spi.Connection;
import lombok.RequiredArgsConstructor;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function;
package org.springframework.data.r2dbc.function;
import io.r2dbc.spi.Row;
import io.r2dbc.spi.RowMetadata;
@@ -31,6 +31,7 @@ import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity;
import org.springframework.data.jdbc.core.mapping.JdbcPersistentProperty;
import org.springframework.data.mapping.PersistentPropertyAccessor;
import org.springframework.data.r2dbc.function.convert.EntityRowMapper;
import org.springframework.data.util.Pair;
import org.springframework.data.util.StreamUtils;
import org.springframework.util.ClassUtils;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function;
package org.springframework.data.r2dbc.function;
import io.r2dbc.spi.Connection;
import io.r2dbc.spi.Result;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function;
package org.springframework.data.r2dbc.function;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function;
package org.springframework.data.r2dbc.function;
import io.r2dbc.spi.Row;
import io.r2dbc.spi.RowMetadata;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function;
package org.springframework.data.r2dbc.function;
import io.r2dbc.spi.Row;
import io.r2dbc.spi.RowMetadata;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function.connectionfactory;
package org.springframework.data.r2dbc.function.connectionfactory;
import io.r2dbc.spi.Connection;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function;
package org.springframework.data.r2dbc.function.convert;
import io.r2dbc.spi.ColumnMetadata;
import io.r2dbc.spi.Row;

View File

@@ -13,8 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function;
package org.springframework.data.r2dbc.function.convert;
import io.r2dbc.spi.Row;
import io.r2dbc.spi.RowMetadata;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@@ -35,9 +37,6 @@ import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
import org.springframework.data.mapping.model.ParameterValueProvider;
import org.springframework.util.ClassUtils;
import io.r2dbc.spi.Row;
import io.r2dbc.spi.RowMetadata;
/**
* Maps a {@link io.r2dbc.spi.Row} to an entity of type {@code T}, including entities referenced.
*

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function;
package org.springframework.data.r2dbc.function.convert;
import java.util.ArrayList;
import java.util.Collection;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.function;
package org.springframework.data.r2dbc.function.convert;
import io.r2dbc.spi.Row;
import io.r2dbc.spi.RowMetadata;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository;
package org.springframework.data.r2dbc.repository;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;

View File

@@ -0,0 +1,7 @@
/**
* R2DBC-specific repository implementation.
*/
@NonNullApi
package org.springframework.data.r2dbc.repository;
import org.springframework.lang.NonNullApi;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.query;
package org.springframework.data.r2dbc.repository.query;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -21,12 +21,14 @@ import reactor.core.publisher.Mono;
import org.reactivestreams.Publisher;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.EntityInstantiators;
import org.springframework.data.jdbc.core.function.DatabaseClient;
import org.springframework.data.jdbc.core.function.DatabaseClient.GenericExecuteSpec;
import org.springframework.data.jdbc.core.function.FetchSpec;
import org.springframework.data.jdbc.core.function.MappingR2dbcConverter;
import org.springframework.data.jdbc.repository.query.R2dbcQueryExecution.ResultProcessingConverter;
import org.springframework.data.jdbc.repository.query.R2dbcQueryExecution.ResultProcessingExecution;
import org.springframework.data.r2dbc.function.DatabaseClient;
import org.springframework.data.r2dbc.function.DatabaseClient.GenericExecuteSpec;
import org.springframework.data.r2dbc.function.FetchSpec;
import org.springframework.data.r2dbc.function.convert.MappingR2dbcConverter;
import org.springframework.data.r2dbc.repository.query.R2dbcQueryExecution.ResultProcessingConverter;
import org.springframework.data.r2dbc.repository.query.R2dbcQueryExecution.ResultProcessingExecution;
import org.springframework.data.relational.repository.query.RelationalParameterAccessor;
import org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor;
import org.springframework.data.repository.query.ParameterAccessor;
import org.springframework.data.repository.query.RepositoryQuery;
import org.springframework.data.repository.query.ResultProcessor;
@@ -79,7 +81,7 @@ public abstract class AbstractR2dbcQuery implements RepositoryQuery {
public Object execute(Object[] parameters) {
return method.hasReactiveWrapperParameter() ? executeDeferred(parameters)
: execute(new JdbcParametersParameterAccessor(method, parameters));
: execute(new RelationalParametersParameterAccessor(method, parameters));
}
@SuppressWarnings("unchecked")
@@ -94,7 +96,7 @@ public abstract class AbstractR2dbcQuery implements RepositoryQuery {
return Mono.defer(() -> (Mono<Object>) execute(parameterAccessor));
}
private Object execute(JdbcParameterAccessor parameterAccessor) {
private Object execute(RelationalParameterAccessor parameterAccessor) {
// TODO: ConvertingParameterAccessor
BindableQuery query = createQuery(parameterAccessor);
@@ -143,5 +145,5 @@ public abstract class AbstractR2dbcQuery implements RepositoryQuery {
* @param accessor must not be {@literal null}.
* @return
*/
protected abstract BindableQuery createQuery(JdbcParameterAccessor accessor);
protected abstract BindableQuery createQuery(RelationalParameterAccessor accessor);
}

View File

@@ -13,22 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.query;
package org.springframework.data.r2dbc.repository.query;
import java.util.function.Supplier;
import org.springframework.data.jdbc.core.function.DatabaseClient.BindSpec;
import org.springframework.data.r2dbc.function.DatabaseClient.BindSpec;
/**
* Interface declaring a query that supplies SQL and can bind parameters to a {@link BindSpec}.
*
*
* @author Mark Paluch
*/
public interface BindableQuery extends Supplier<String> {
/**
* Bind parameters to the {@link BindSpec query}.
*
*
* @param bindSpec must not be {@literal null}.
* @return the bound query object.
*/

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.query;
package org.springframework.data.r2dbc.repository.query;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -22,6 +22,7 @@ import reactor.core.publisher.MonoProcessor;
import java.util.ArrayList;
import java.util.List;
import org.springframework.data.relational.repository.query.RelationalParametersParameterAccessor;
import org.springframework.data.repository.util.ReactiveWrapperConverters;
import org.springframework.data.repository.util.ReactiveWrappers;
@@ -31,7 +32,7 @@ import org.springframework.data.repository.util.ReactiveWrappers;
*
* @author Mark Paluch
*/
class R2dbcParameterAccessor extends JdbcParametersParameterAccessor {
class R2dbcParameterAccessor extends RelationalParametersParameterAccessor {
private final Object[] values;
private final List<MonoProcessor<?>> subscriptions;

View File

@@ -13,17 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.query;
package org.springframework.data.r2dbc.repository.query;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.EntityInstantiators;
import org.springframework.data.jdbc.core.function.FetchSpec;
import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity;
import org.springframework.data.jdbc.core.mapping.JdbcPersistentProperty;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.r2dbc.function.FetchSpec;
import org.springframework.data.relational.repository.query.DtoInstantiatingConverter;
import org.springframework.data.repository.query.ResultProcessor;
import org.springframework.data.repository.query.ReturnedType;
import org.springframework.util.ClassUtils;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.query;
package org.springframework.data.r2dbc.repository.query;
import static org.springframework.data.repository.util.ClassUtils.*;
@@ -28,10 +28,14 @@ import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort;
import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity;
import org.springframework.data.jdbc.core.mapping.JdbcPersistentProperty;
import org.springframework.data.jdbc.repository.query.JdbcParameters.JdbcParameter;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.relational.repository.query.RelationalEntityMetadata;
import org.springframework.data.relational.repository.query.RelationalParameters;
import org.springframework.data.relational.repository.query.SimpleRelationalEntityMetadata;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.data.repository.query.Parameter;
import org.springframework.data.repository.query.QueryMethod;
import org.springframework.data.repository.util.ReactiveWrapperConverters;
import org.springframework.data.repository.util.ReactiveWrappers;
@@ -55,7 +59,7 @@ public class R2dbcQueryMethod extends QueryMethod {
private final MappingContext<? extends JdbcPersistentEntity<?>, JdbcPersistentProperty> mappingContext;
private final Optional<Query> query;
private @Nullable JdbcEntityMetadata<?> metadata;
private @Nullable RelationalEntityMetadata<?> metadata;
/**
* Creates a new {@link R2dbcQueryMethod} from the given {@link Method}.
@@ -109,8 +113,8 @@ public class R2dbcQueryMethod extends QueryMethod {
* @see org.springframework.data.repository.query.QueryMethod#createParameters(java.lang.reflect.Method)
*/
@Override
protected JdbcParameters createParameters(Method method) {
return new JdbcParameters(method);
protected RelationalParameters createParameters(Method method) {
return new RelationalParameters(method);
}
/* (non-Javadoc)
@@ -144,7 +148,7 @@ public class R2dbcQueryMethod extends QueryMethod {
*/
@Override
@SuppressWarnings("unchecked")
public JdbcEntityMetadata<?> getEntityInformation() {
public RelationalEntityMetadata<?> getEntityInformation() {
if (metadata == null) {
@@ -153,7 +157,7 @@ public class R2dbcQueryMethod extends QueryMethod {
if (ClassUtils.isPrimitiveOrWrapper(returnedObjectType)) {
this.metadata = new SimpleJdbcEntityMetadata<>((Class<Object>) domainClass,
this.metadata = new SimpleRelationalEntityMetadata<>((Class<Object>) domainClass,
mappingContext.getRequiredPersistentEntity(domainClass));
} else {
@@ -165,7 +169,7 @@ public class R2dbcQueryMethod extends QueryMethod {
JdbcPersistentEntity<?> tableEntity = domainClass.isAssignableFrom(returnedObjectType) ? returnedEntity
: managedEntity;
this.metadata = new SimpleJdbcEntityMetadata<>((Class<Object>) returnedEntity.getType(), tableEntity);
this.metadata = new SimpleRelationalEntityMetadata<>((Class<Object>) returnedEntity.getType(), tableEntity);
}
}
@@ -176,8 +180,8 @@ public class R2dbcQueryMethod extends QueryMethod {
* @see org.springframework.data.repository.query.QueryMethod#getParameters()
*/
@Override
public JdbcParameters getParameters() {
return (JdbcParameters) super.getParameters();
public RelationalParameters getParameters() {
return (RelationalParameters) super.getParameters();
}
/**
@@ -189,7 +193,7 @@ public class R2dbcQueryMethod extends QueryMethod {
*/
public boolean hasReactiveWrapperParameter() {
for (JdbcParameter parameter : getParameters()) {
for (Parameter parameter : getParameters()) {
if (ReactiveWrapperConverters.supports(parameter.getType())) {
return true;
}

View File

@@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.query;
package org.springframework.data.r2dbc.repository.query;
import org.springframework.data.jdbc.core.function.DatabaseClient;
import org.springframework.data.jdbc.core.function.DatabaseClient.BindSpec;
import org.springframework.data.jdbc.core.function.MappingR2dbcConverter;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.r2dbc.function.DatabaseClient;
import org.springframework.data.r2dbc.function.DatabaseClient.BindSpec;
import org.springframework.data.r2dbc.function.convert.MappingR2dbcConverter;
import org.springframework.data.relational.repository.query.RelationalParameterAccessor;
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.util.Assert;
@@ -76,7 +78,7 @@ public class StringBasedR2dbcQuery extends AbstractR2dbcQuery {
* @see org.springframework.data.jdbc.repository.query.AbstractR2dbcQuery#createQuery(org.springframework.data.jdbc.repository.query.JdbcParameterAccessor)
*/
@Override
protected BindableQuery createQuery(JdbcParameterAccessor accessor) {
protected BindableQuery createQuery(RelationalParameterAccessor accessor) {
return new BindableQuery() {

View File

@@ -0,0 +1,9 @@
/**
* Query support for R2DBC repositories.
*/
@NonNullApi
@NonNullFields
package org.springframework.data.r2dbc.repository.query;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.support;
package org.springframework.data.r2dbc.repository.support;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
@@ -21,15 +21,17 @@ import lombok.RequiredArgsConstructor;
import java.lang.reflect.Method;
import java.util.Optional;
import org.springframework.data.jdbc.core.function.DatabaseClient;
import org.springframework.data.jdbc.core.function.MappingR2dbcConverter;
import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity;
import org.springframework.data.jdbc.core.mapping.JdbcPersistentProperty;
import org.springframework.data.jdbc.repository.query.JdbcEntityInformation;
import org.springframework.data.jdbc.repository.query.R2dbcQueryMethod;
import org.springframework.data.jdbc.repository.query.StringBasedR2dbcQuery;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.r2dbc.function.DatabaseClient;
import org.springframework.data.r2dbc.function.convert.MappingR2dbcConverter;
import org.springframework.data.r2dbc.repository.R2dbcRepository;
import org.springframework.data.r2dbc.repository.query.R2dbcQueryMethod;
import org.springframework.data.r2dbc.repository.query.StringBasedR2dbcQuery;
import org.springframework.data.relational.repository.query.RelationalEntityInformation;
import org.springframework.data.relational.repository.support.MappingRelationalEntityInformation;
import org.springframework.data.repository.core.NamedQueries;
import org.springframework.data.repository.core.RepositoryInformation;
import org.springframework.data.repository.core.RepositoryMetadata;
@@ -43,7 +45,7 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
* Factory to create {@link org.springframework.data.jdbc.repository.R2dbcRepository} instances.
* Factory to create {@link R2dbcRepository} instances.
*
* @author Mark Paluch
*/
@@ -88,7 +90,8 @@ public class R2dbcRepositoryFactory extends ReactiveRepositoryFactorySupport {
@Override
protected Object getTargetRepository(RepositoryInformation information) {
JdbcEntityInformation<?, ?> entityInformation = getEntityInformation(information.getDomainType(), information);
RelationalEntityInformation<?, ?> entityInformation = getEntityInformation(information.getDomainType(),
information);
return getTargetRepositoryViaReflection(information, entityInformation, databaseClient, converter);
}
@@ -107,17 +110,17 @@ public class R2dbcRepositoryFactory extends ReactiveRepositoryFactorySupport {
* (non-Javadoc)
* @see org.springframework.data.repository.core.support.RepositoryFactorySupport#getEntityInformation(java.lang.Class)
*/
public <T, ID> JdbcEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
public <T, ID> RelationalEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
return getEntityInformation(domainClass, null);
}
@SuppressWarnings("unchecked")
private <T, ID> JdbcEntityInformation<T, ID> getEntityInformation(Class<T> domainClass,
private <T, ID> RelationalEntityInformation<T, ID> getEntityInformation(Class<T> domainClass,
@Nullable RepositoryInformation information) {
JdbcPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(domainClass);
return new MappingJdbcEntityInformation<>((JdbcPersistentEntity<T>) entity);
return new MappingRelationalEntityInformation<>((JdbcPersistentEntity<T>) entity);
}
/**

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.support;
package org.springframework.data.r2dbc.repository.support;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@@ -27,12 +27,12 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.reactivestreams.Publisher;
import org.springframework.data.jdbc.core.function.DatabaseClient;
import org.springframework.data.jdbc.core.function.DatabaseClient.BindSpec;
import org.springframework.data.jdbc.core.function.DatabaseClient.GenericExecuteSpec;
import org.springframework.data.jdbc.core.function.FetchSpec;
import org.springframework.data.jdbc.core.function.MappingR2dbcConverter;
import org.springframework.data.jdbc.repository.query.JdbcEntityInformation;
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.convert.MappingR2dbcConverter;
import org.springframework.data.relational.repository.query.RelationalEntityInformation;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.util.Assert;
@@ -44,7 +44,7 @@ import org.springframework.util.Assert;
@RequiredArgsConstructor
public class SimpleR2dbcRepository<T, ID> implements ReactiveCrudRepository<T, ID> {
private final @NonNull JdbcEntityInformation<T, ID> entity;
private final @NonNull RelationalEntityInformation<T, ID> entity;
private final @NonNull DatabaseClient databaseClient;
private final @NonNull MappingR2dbcConverter converter;

View File

@@ -0,0 +1,7 @@
/**
* Support infrastructure for query derivation of R2DBC-specific repositories.
*/
@NonNullApi
package org.springframework.data.r2dbc.repository.support;
import org.springframework.lang.NonNullApi;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.query;
package org.springframework.data.relational.repository.query;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.EntityInstantiator;
@@ -35,7 +35,7 @@ import org.springframework.util.Assert;
*
* @author Mark Paluch
*/
class DtoInstantiatingConverter implements Converter<Object, Object> {
public class DtoInstantiatingConverter implements Converter<Object, Object> {
private final Class<?> targetType;
private final MappingContext<? extends PersistentEntity<?, ?>, ? extends PersistentProperty<?>> context;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.query;
package org.springframework.data.relational.repository.query;
import org.springframework.data.repository.core.EntityInformation;
@@ -22,7 +22,7 @@ import org.springframework.data.repository.core.EntityInformation;
*
* @author Mark Paluch
*/
public interface JdbcEntityInformation<T, ID> extends EntityInformation<T, ID> {
public interface RelationalEntityInformation<T, ID> extends EntityInformation<T, ID> {
/**
* Returns the name of the table the entity shall be persisted to.

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.query;
package org.springframework.data.relational.repository.query;
import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity;
import org.springframework.data.repository.core.EntityMetadata;
@@ -23,7 +23,7 @@ import org.springframework.data.repository.core.EntityMetadata;
*
* @author Mark Paluch
*/
public interface JdbcEntityMetadata<T> extends EntityMetadata<T> {
public interface RelationalEntityMetadata<T> extends EntityMetadata<T> {
/**
* Returns the name of the table the entity shall be persisted to.

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.query;
package org.springframework.data.relational.repository.query;
import org.springframework.data.repository.query.ParameterAccessor;
@@ -22,7 +22,7 @@ import org.springframework.data.repository.query.ParameterAccessor;
*
* @author Mark Paluch
*/
public interface JdbcParameterAccessor extends ParameterAccessor {
public interface RelationalParameterAccessor extends ParameterAccessor {
/**
* Returns the raw parameter values of the underlying query method.

View File

@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.query;
package org.springframework.data.relational.repository.query;
import java.lang.reflect.Method;
import java.util.List;
import org.springframework.core.MethodParameter;
import org.springframework.data.jdbc.repository.query.JdbcParameters.JdbcParameter;
import org.springframework.data.relational.repository.query.RelationalParameters.RelationalParameter;
import org.springframework.data.repository.query.Parameter;
import org.springframework.data.repository.query.Parameters;
@@ -28,18 +28,18 @@ import org.springframework.data.repository.query.Parameters;
*
* @author Mark Paluch
*/
public class JdbcParameters extends Parameters<JdbcParameters, JdbcParameter> {
public class RelationalParameters extends Parameters<RelationalParameters, RelationalParameter> {
/**
* Creates a new {@link JdbcParameters} instance from the given {@link Method}.
* Creates a new {@link RelationalParameters} instance from the given {@link Method}.
*
* @param method must not be {@literal null}.
*/
public JdbcParameters(Method method) {
public RelationalParameters(Method method) {
super(method);
}
private JdbcParameters(List<JdbcParameter> parameters) {
private RelationalParameters(List<RelationalParameter> parameters) {
super(parameters);
}
@@ -48,8 +48,8 @@ public class JdbcParameters extends Parameters<JdbcParameters, JdbcParameter> {
* @see org.springframework.data.repository.query.Parameters#createParameter(org.springframework.core.MethodParameter)
*/
@Override
protected JdbcParameter createParameter(MethodParameter parameter) {
return new JdbcParameter(parameter);
protected RelationalParameter createParameter(MethodParameter parameter) {
return new RelationalParameter(parameter);
}
/*
@@ -57,8 +57,8 @@ public class JdbcParameters extends Parameters<JdbcParameters, JdbcParameter> {
* @see org.springframework.data.repository.query.Parameters#createFrom(java.util.List)
*/
@Override
protected JdbcParameters createFrom(List<JdbcParameter> parameters) {
return new JdbcParameters(parameters);
protected RelationalParameters createFrom(List<RelationalParameter> parameters) {
return new RelationalParameters(parameters);
}
/**
@@ -66,14 +66,14 @@ public class JdbcParameters extends Parameters<JdbcParameters, JdbcParameter> {
*
* @author Mark Paluch
*/
class JdbcParameter extends Parameter {
public static class RelationalParameter extends Parameter {
/**
* Creates a new {@link JdbcParameter}.
* Creates a new {@link RelationalParameter}.
*
* @param parameter must not be {@literal null}.
*/
JdbcParameter(MethodParameter parameter) {
RelationalParameter(MethodParameter parameter) {
super(parameter);
}
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.query;
package org.springframework.data.relational.repository.query;
import java.util.Arrays;
import java.util.List;
@@ -26,17 +26,18 @@ import org.springframework.data.repository.query.QueryMethod;
*
* @author Mark Paluch
*/
public class JdbcParametersParameterAccessor extends ParametersParameterAccessor implements JdbcParameterAccessor {
public class RelationalParametersParameterAccessor extends ParametersParameterAccessor
implements RelationalParameterAccessor {
private final List<Object> values;
/**
* Creates a new {@link JdbcParametersParameterAccessor}.
* Creates a new {@link RelationalParametersParameterAccessor}.
*
* @param method must not be {@literal null}.
* @param values must not be {@literal null}.
*/
public JdbcParametersParameterAccessor(QueryMethod method, Object[] values) {
public RelationalParametersParameterAccessor(QueryMethod method, Object[] values) {
super(method.getParameters(), values);
this.values = Arrays.asList(values);

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.query;
package org.springframework.data.relational.repository.query;
import lombok.Getter;
@@ -21,23 +21,23 @@ import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity;
import org.springframework.util.Assert;
/**
* Default implementation of {@link JdbcEntityMetadata}.
* Default implementation of {@link RelationalEntityMetadata}.
*
* @author Mark Paluch
*/
class SimpleJdbcEntityMetadata<T> implements JdbcEntityMetadata<T> {
public class SimpleRelationalEntityMetadata<T> implements RelationalEntityMetadata<T> {
private final Class<T> type;
private final @Getter JdbcPersistentEntity<?> tableEntity;
/**
* Creates a new {@link SimpleJdbcEntityMetadata} using the given type and {@link JdbcPersistentEntity} to use for
* table lookups.
* Creates a new {@link SimpleRelationalEntityMetadata} using the given type and {@link JdbcPersistentEntity} to use
* for table lookups.
*
* @param type must not be {@literal null}.
* @param tableEntity must not be {@literal null}.
*/
SimpleJdbcEntityMetadata(Class<T> type, JdbcPersistentEntity<?> tableEntity) {
public SimpleRelationalEntityMetadata(Class<T> type, JdbcPersistentEntity<?> tableEntity) {
Assert.notNull(type, "Type must not be null!");
Assert.notNull(tableEntity, "Table entity must not be null!");

View File

@@ -0,0 +1,7 @@
/**
* Query support for relational database repositories.
*/
@NonNullApi
package org.springframework.data.relational.repository.query;
import org.springframework.lang.NonNullApi;

View File

@@ -13,69 +13,69 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.repository.support;
package org.springframework.data.relational.repository.support;
import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity;
import org.springframework.data.jdbc.repository.query.JdbcEntityInformation;
import org.springframework.data.relational.repository.query.RelationalEntityInformation;
import org.springframework.data.repository.core.support.PersistentEntityInformation;
import org.springframework.lang.Nullable;
import com.sun.corba.se.spi.ior.ObjectId;
/**
* {@link JdbcEntityInformation} implementation using a {@link JdbcPersistentEntity} instance to lookup the necessary
* information. Can be configured with a custom table name.
* {@link RelationalEntityInformation} implementation using a {@link JdbcPersistentEntity} instance to lookup the
* necessary information. Can be configured with a custom table name.
*
* @author Mark Paluch
*/
public class MappingJdbcEntityInformation<T, ID> extends PersistentEntityInformation<T, ID>
implements JdbcEntityInformation<T, ID> {
public class MappingRelationalEntityInformation<T, ID> extends PersistentEntityInformation<T, ID>
implements RelationalEntityInformation<T, ID> {
private final JdbcPersistentEntity<T> entityMetadata;
private final @Nullable String customTableName;
private final Class<ID> fallbackIdType;
/**
* Creates a new {@link MappingJdbcEntityInformation} for the given {@link JdbcPersistentEntity}.
* Creates a new {@link MappingRelationalEntityInformation} for the given {@link JdbcPersistentEntity}.
*
* @param entity must not be {@literal null}.
*/
public MappingJdbcEntityInformation(JdbcPersistentEntity<T> entity) {
public MappingRelationalEntityInformation(JdbcPersistentEntity<T> entity) {
this(entity, null, null);
}
/**
* Creates a new {@link MappingJdbcEntityInformation} for the given {@link JdbcPersistentEntity} and fallback
* Creates a new {@link MappingRelationalEntityInformation} for the given {@link JdbcPersistentEntity} and fallback
* identifier type.
*
* @param entity must not be {@literal null}.
* @param fallbackIdType can be {@literal null}.
*/
public MappingJdbcEntityInformation(JdbcPersistentEntity<T> entity, @Nullable Class<ID> fallbackIdType) {
public MappingRelationalEntityInformation(JdbcPersistentEntity<T> entity, @Nullable Class<ID> fallbackIdType) {
this(entity, null, fallbackIdType);
}
/**
* Creates a new {@link MappingJdbcEntityInformation} for the given {@link JdbcPersistentEntity} and custom table
* name.
* Creates a new {@link MappingRelationalEntityInformation} for the given {@link JdbcPersistentEntity} and custom
* table name.
*
* @param entity must not be {@literal null}.
* @param customTableName can be {@literal null}.
*/
public MappingJdbcEntityInformation(JdbcPersistentEntity<T> entity, String customTableName) {
public MappingRelationalEntityInformation(JdbcPersistentEntity<T> entity, String customTableName) {
this(entity, customTableName, null);
}
/**
* Creates a new {@link MappingJdbcEntityInformation} for the given {@link JdbcPersistentEntity}, collection name and
* identifier type.
* Creates a new {@link MappingRelationalEntityInformation} for the given {@link JdbcPersistentEntity}, collection
* name and identifier type.
*
* @param entity must not be {@literal null}.
* @param customTableName can be {@literal null}.
* @param idType can be {@literal null}.
*/
@SuppressWarnings("unchecked")
private MappingJdbcEntityInformation(JdbcPersistentEntity<T> entity, @Nullable String customTableName,
private MappingRelationalEntityInformation(JdbcPersistentEntity<T> entity, @Nullable String customTableName,
@Nullable Class<ID> idType) {
super(entity);

View File

@@ -0,0 +1,7 @@
/**
* Support infrastructure for query derivation of relational database repositories.
*/
@NonNullApi
package org.springframework.data.relational.repository.support;
import org.springframework.lang.NonNullApi;