use of org.springframework.cloud.gcp.data.spanner.core.convert.StructAccessor in project spring-cloud-gcp by spring-cloud.
the class SqlSpannerQuery method executeReadSql.
private List executeReadSql(Pageable pageable, Sort sort, QueryTagValue queryTagValue) {
SpannerPageableQueryOptions spannerQueryOptions = new SpannerPageableQueryOptions().setAllowPartialRead(true);
if (sort != null && sort.isSorted()) {
spannerQueryOptions.setSort(sort);
}
if (pageable != null && pageable.isPaged()) {
spannerQueryOptions.setOffset(pageable.getOffset()).setLimit(pageable.getPageSize());
}
final Class<?> returnedType = getReturnedType();
final SpannerPersistentEntity<?> entity = returnedType == null ? null : this.spannerMappingContext.getPersistentEntity(returnedType);
queryTagValue.sql = SpannerStatementQueryExecutor.applySortingPagingQueryOptions(this.entityType, spannerQueryOptions, queryTagValue.sql, this.spannerMappingContext, entity != null && entity.hasEagerlyLoadedProperties());
Statement statement = buildStatementFromQueryAndTags(queryTagValue);
return (getReturnedSimpleConvertableItemType() != null) ? this.spannerTemplate.query((struct) -> new StructAccessor(struct).getSingleValue(0), statement, spannerQueryOptions) : this.spannerTemplate.query(this.entityType, statement, spannerQueryOptions);
}
Aggregations