本文整理汇总了Java中org.springframework.data.repository.query.ParametersParameterAccessor类的典型用法代码示例。如果您正苦于以下问题:Java ParametersParameterAccessor类的具体用法?Java ParametersParameterAccessor怎么用?Java ParametersParameterAccessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParametersParameterAccessor类属于org.springframework.data.repository.query包,在下文中一共展示了ParametersParameterAccessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExecute
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected Object doExecute(final AbstractEbeanQuery repositoryQuery, final Object[] values) {
ParameterAccessor accessor = new ParametersParameterAccessor(parameters, values);
Object createQuery = repositoryQuery.createQuery(values);
if (createQuery instanceof Query) {
Query ormQuery = (Query) createQuery;
PagedList pagedList = ormQuery.findPagedList();
return PageableExecutionUtils.getPage(pagedList.getList(), accessor.getPageable(), () -> pagedList.getTotalCount());
} else if (createQuery instanceof SqlQuery) {
SqlQuery sqlQuery = (SqlQuery) createQuery;
// TODO page
return sqlQuery.findList();
} else {
throw new InvalidEbeanQueryMethodException("query must be Query or SqlQuery");
}
}
示例2: doCreateQuery
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
@Override
protected Query doCreateQuery(Object[] values) {
String nativeQuery = getQuery(values);
JpaParameters parameters = getQueryMethod().getParameters();
ParameterAccessor accessor = new ParametersParameterAccessor(parameters, values);
String sortedQueryString = QueryUtils
.applySorting(nativeQuery, accessor.getSort(), QueryUtils.detectAlias(nativeQuery));
Query query = bind(createJpaQuery(sortedQueryString), values);
if (parameters.hasPageableParameter()) {
Pageable pageable = (Pageable) (values[parameters.getPageableIndex()]);
if (pageable != null) {
query.setFirstResult(pageable.getOffset());
query.setMaxResults(pageable.getPageSize());
}
}
return query;
}
示例3: createQueryForMethodWithArgs
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
private KeyValueQuery<SpelExpression> createQueryForMethodWithArgs(String methodName, Object... args)
throws NoSuchMethodException, SecurityException {
Class<?>[] argTypes = new Class<?>[args.length];
if (!ObjectUtils.isEmpty(args)) {
for (int i = 0; i < args.length; i++) {
argTypes[i] = args[i].getClass();
}
}
Method method = PersonRepository.class.getMethod(methodName, argTypes);
doReturn(Person.class).when(metadataMock).getReturnedDomainClass(method);
PartTree partTree = new PartTree(method.getName(), method.getReturnType());
SpelQueryCreator creator = new SpelQueryCreator(partTree, new ParametersParameterAccessor(
new QueryMethod(method, metadataMock, new SpelAwareProxyProjectionFactory()).getParameters(), args));
KeyValueQuery<SpelExpression> q = creator.createQuery();
q.getCriteria().setEvaluationContext(new StandardEvaluationContext(args));
return q;
}
示例4: createQueryForMethodWithArgs
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
private static SpelCriteria createQueryForMethodWithArgs(String methodName, Object... args) throws Exception {
List<Class<?>> types = new ArrayList<>(args.length);
for (Object arg : args) {
types.add(arg.getClass());
}
Method method = PersonRepository.class.getMethod(methodName, types.toArray(new Class<?>[types.size()]));
RepositoryMetadata metadata = mock(RepositoryMetadata.class);
doReturn(method.getReturnType()).when(metadata).getReturnedDomainClass(method);
PartTree partTree = new PartTree(method.getName(), method.getReturnType());
SpelQueryCreator creator = new SpelQueryCreator(partTree, new ParametersParameterAccessor(
new QueryMethod(method, metadata, new SpelAwareProxyProjectionFactory()).getParameters(), args));
return new SpelCriteria(creator.createQuery().getCriteria(), new StandardEvaluationContext(args));
}
示例5: createQueryCreatorForMethodWithArgs
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
private TarantoolQueryCreator createQueryCreatorForMethodWithArgs(Method method, Object[] args) {
PartTree partTree = new PartTree(method.getName(), method.getReturnType());
TarantoolQueryCreator creator = new TarantoolQueryCreator(partTree, new ParametersParameterAccessor(new DefaultParameters(
method), args));
return creator;
}
示例6: createQuery
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
protected BaseQuery<?> createQuery(ParametersParameterAccessor accessor) {
Class<?> entityClass = getQueryMethod().getEntityInformation().getJavaType();
CriteriaQuery<?> query = new SnowdropQueryCreator(entityClass, tree, accessor, mappingContext).createQuery();
query.setTargetFields(TargetFieldsUtils.getTargetFieldsMap(getQueryMethod()));
query.setMaxResults(tree.getMaxResults());
query.setDistinct(tree.isDistinct());
return query;
}
示例7: replacePlaceholders
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
private String replacePlaceholders(String input, ParametersParameterAccessor accessor) {
Matcher matcher = PARAMETER_PLACEHOLDER.matcher(input);
String result = input;
while (matcher.find()) {
String group = matcher.group();
int index = Integer.parseInt(matcher.group(1));
result = result.replace(group, getParameterWithIndex(accessor, index));
}
return result;
}
示例8: getParameterWithIndex
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
private String getParameterWithIndex(ParametersParameterAccessor accessor, int index) {
Object parameter = accessor.getBindableValue(index);
if (parameter == null) {
return "null";
}
if (conversionService.canConvert(parameter.getClass(), String.class)) {
return conversionService.convert(parameter, String.class);
}
return parameter.toString();
}
示例9: getProjection
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
protected Class<?> getProjection(ParametersParameterAccessor accessor) {
Optional<Class<?>> dp = accessor.getDynamicProjection();
if (dp.isPresent()) {
return dp.get();
}
Class<?> returnType = getQueryMethod().getReturnedObjectType();
if (returnType.isInterface()) {
return returnType;
}
// TODO - handle DTO
return null;
}
示例10: execute
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
@Override
public Object execute(Object[] parameters) {
ParametersParameterAccessor accessor = new ParametersParameterAccessor(getQueryMethod().getParameters(), parameters);
ResultProcessor resultProcessor = getQueryMethod().getResultProcessor().withDynamicProjection(accessor);
Object source = executeInternal(accessor);
return resultProcessor.processResult(source);
}
示例11: createCreator
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
private GcloudDatastoreQueryCreator createCreator(Class<?> repositoryClass,
Method method, Object... values) {
QueryMethod queryMethod = new QueryMethod(method,
new DefaultRepositoryMetadata(repositoryClass),
new SpelAwareProxyProjectionFactory());
return new GcloudDatastoreQueryCreator(
new PartTree(method.getName(),
queryMethod.getResultProcessor().getReturnedType()
.getDomainType()),
new ParametersParameterAccessor(queryMethod.getParameters(), values),
DatastoreOptions.getDefaultInstance());
}
示例12: execute
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
@Override
public Object execute(Object[] parameters) {
ParameterAccessor accessor = new ParametersParameterAccessor(getQueryMethod().getParameters(), parameters);
ResultProcessor processor = queryMethod.getResultProcessor().withDynamicProjection(accessor);
return processor.processResult(doExecute(parameters));
}
示例13: doCreateQuery
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
@Override
public Object doCreateQuery(Object[] values) {
ParameterAccessor accessor = new ParametersParameterAccessor(getQueryMethod().getParameters(), values);
Object query = createEbeanQuery(this.query.getQueryString());
return createBinder(values).bindAndPrepare(query);
}
示例14: createCreator
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
protected EbeanQueryCreator createCreator(ParametersParameterAccessor accessor) {
EbeanServer ebeanServer = getEbeanServer();
Query ebeanQuery = ebeanServer.createQuery(domainClass);
ExpressionList expressionList = ebeanQuery.where();
ParameterMetadataProvider provider = new ParameterMetadataProvider(accessor);
ResultProcessor processor = getQueryMethod().getResultProcessor();
return new EbeanQueryCreator(tree, processor.getReturnedType(), expressionList, provider);
}
示例15: ParameterBinder
import org.springframework.data.repository.query.ParametersParameterAccessor; //导入依赖的package包/类
/**
* Creates a new {@link ParameterBinder}.
*
* @param parameters must not be {@literal null}.
* @param values must not be {@literal null}.
*/
public ParameterBinder(DefaultParameters parameters, Object[] values) {
Assert.notNull(parameters, "Parameters must not be null!");
Assert.notNull(values, "Values must not be null!");
Assert.isTrue(parameters.getNumberOfParameters() == values.length, "Invalid number of parameters given!");
this.parameters = parameters;
this.values = values.clone();
this.accessor = new ParametersParameterAccessor(parameters, this.values);
}