当前位置: 首页>>代码示例>>Java>>正文


Java ParametersParameterAccessor类代码示例

本文整理汇总了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");
  }
}
 
开发者ID:hexagonframework,项目名称:spring-data-ebean,代码行数:19,代码来源:AbstractEbeanQueryExecution.java

示例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;
}
 
开发者ID:slyak,项目名称:spring-data-jpa-extra,代码行数:18,代码来源:FreemarkerTemplateQuery.java

示例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;
}
 
开发者ID:spring-projects,项目名称:spring-data-keyvalue,代码行数:24,代码来源:SpelQueryCreatorUnitTests.java

示例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));
	}
 
开发者ID:spring-projects,项目名称:spring-data-keyvalue,代码行数:19,代码来源:SpelQueryEngineUnitTests.java

示例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;
    }
 
开发者ID:saladinkzn,项目名称:spring-data-tarantool,代码行数:9,代码来源:TarantoolQueryCreatorTest.java

示例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;
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:12,代码来源:SnowdropPartQuery.java

示例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;
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:11,代码来源:SnowdropStringQuery.java

示例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();
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:11,代码来源:SnowdropStringQuery.java

示例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;
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:13,代码来源:AbstractSnowdropRepositoryQuery.java

示例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);
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:8,代码来源:AbstractSnowdropRepositoryQuery.java

示例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());
}
 
开发者ID:tkob,项目名称:spring-data-gclouddatastore,代码行数:14,代码来源:GcloudDatastoreQueryCreatorTests.java

示例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));
}
 
开发者ID:nhuttrung,项目名称:spring-data-objectify,代码行数:8,代码来源:ObjectifyRepositoryQuery.java

示例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);
}
 
开发者ID:hexagonframework,项目名称:spring-data-ebean,代码行数:8,代码来源:AbstractStringBasedEbeanQuery.java

示例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);
}
 
开发者ID:hexagonframework,项目名称:spring-data-ebean,代码行数:12,代码来源:PartTreeEbeanQuery.java

示例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);
}
 
开发者ID:hexagonframework,项目名称:spring-data-ebean,代码行数:18,代码来源:ParameterBinder.java


注:本文中的org.springframework.data.repository.query.ParametersParameterAccessor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。