public final class SpannerStatementQueryExecutor extends Object
PartTree parsed method
definitions.| Modifier and Type | Method and Description |
|---|---|
static StringBuilder |
applySort(org.springframework.data.domain.Sort sort,
StringBuilder sql,
Function<org.springframework.data.domain.Sort.Order,String> sortedPropertyNameFunction) |
static <T> String |
applySortingPagingQueryOptions(Class<T> entityClass,
SpannerPageableQueryOptions options,
String sql,
SpannerMappingContext mappingContext)
Apply paging and sorting options to a query string.
|
static com.google.cloud.spanner.Statement |
buildStatementFromSqlWithArgs(String sql,
List<String> tags,
Function<Object,com.google.cloud.spanner.Struct> paramStructConvertFunc,
SpannerCustomConverter spannerCustomConverter,
Object[] params)
Creates a Cloud Spanner statement.
|
static <T> List<T> |
executeQuery(Class<T> type,
org.springframework.data.repository.query.parser.PartTree tree,
Object[] params,
SpannerTemplate spannerTemplate,
SpannerMappingContext spannerMappingContext)
Executes a PartTree-based query.
|
static <A,T> List<A> |
executeQuery(Function<com.google.cloud.spanner.Struct,A> rowFunc,
Class<T> type,
org.springframework.data.repository.query.parser.PartTree tree,
Object[] params,
SpannerTemplate spannerTemplate,
SpannerMappingContext spannerMappingContext)
Executes a PartTree-based query and applies a custom row-mapping function to the
result.
|
static <T> com.google.cloud.spanner.Statement |
getChildrenRowsQuery(com.google.cloud.spanner.Key parentKey,
SpannerPersistentEntity<T> childPersistentEntity)
Gets a query that returns the rows associated with a parent entity.
|
static String |
getColumnsStringForSelect(SpannerPersistentEntity spannerPersistentEntity) |
public static <T> List<T> executeQuery(Class<T> type, org.springframework.data.repository.query.parser.PartTree tree, Object[] params, SpannerTemplate spannerTemplate, SpannerMappingContext spannerMappingContext)
T - the type of the underlying entitytype - the type of the underlying entitytree - the parsed metadata of the queryparams - the parameters of this specific queryspannerTemplate - used to execute the queryspannerMappingContext - used to get metadata about the entity typepublic static <A,T> List<A> executeQuery(Function<com.google.cloud.spanner.Struct,A> rowFunc, Class<T> type, org.springframework.data.repository.query.parser.PartTree tree, Object[] params, SpannerTemplate spannerTemplate, SpannerMappingContext spannerMappingContext)
A - the type to which to convert Struct paramsT - the type of the underlying entity on which to queryrowFunc - the function to apply to each row of the result.type - the type of the underlying entitytree - the parsed metadata of the queryparams - the parameters of this specific queryspannerTemplate - used to execute the queryspannerMappingContext - used to get metadata about the entity typepublic static <T> String applySortingPagingQueryOptions(Class<T> entityClass, SpannerPageableQueryOptions options, String sql, SpannerMappingContext mappingContext)
T - the domain type.entityClass - the domain type whose table is being queried.options - query options containing the sorting and paging optionssql - the sql that will be wrapped with sorting and paging options.mappingContext - a mapping context to convert between Cloud Spanner column names
and underlying property names.public static <T> com.google.cloud.spanner.Statement getChildrenRowsQuery(com.google.cloud.spanner.Key parentKey,
SpannerPersistentEntity<T> childPersistentEntity)
T - the type of the child persistent entityparentKey - the parent key whose children to get.childPersistentEntity - the persistent entity of the child table.public static com.google.cloud.spanner.Statement buildStatementFromSqlWithArgs(String sql, List<String> tags, Function<Object,com.google.cloud.spanner.Struct> paramStructConvertFunc, SpannerCustomConverter spannerCustomConverter, Object[] params)
sql - the SQL string with tags.tags - the tags that appear in the SQL string.paramStructConvertFunc - a function to use to convert params to Struct
objects if they cannot be directly mapped to Cloud Spanner supported param types.
If null then this last-attempt conversion is skipped.spannerCustomConverter - a converter used to convert params that aren't Cloud
Spanner native types. if null then this conversion is not attempted.params - the parameters to substitute the tags. The ordering must be the same as
the tags.IllegalArgumentException - if the number of tags does not match the number of
params, or if a param of an unsupported type is given.public static String getColumnsStringForSelect(SpannerPersistentEntity spannerPersistentEntity)
public static StringBuilder applySort(org.springframework.data.domain.Sort sort, StringBuilder sql, Function<org.springframework.data.domain.Sort.Order,String> sortedPropertyNameFunction)
Copyright © 2019 Pivotal Software, Inc.. All rights reserved.