@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"); } }
@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; }
@Override public Object execute(Object[] parameters) { ParameterAccessor accessor = new ParametersParameterAccessor(getQueryMethod().getParameters(), parameters); ResultProcessor processor = queryMethod.getResultProcessor().withDynamicProjection(accessor); return processor.processResult(doExecute(parameters)); }
@Override public Object doCreateQuery(Object[] values) { ParameterAccessor accessor = new ParametersParameterAccessor(getQueryMethod().getParameters(), values); Object query = createEbeanQuery(this.query.getQueryString()); return createBinder(values).bindAndPrepare(query); }
/** * Create a new {@link VaultQueryCreator} given {@link PartTree} and * {@link ParameterAccessor}. * * @param tree must not be {@literal null}. * @param parameters must not be {@literal null}. * @param mappingContext must not be {@literal null}. */ public VaultQueryCreator( PartTree tree, ParameterAccessor parameters, MappingContext<VaultPersistentEntity<?>, VaultPersistentProperty> mappingContext) { super(tree, parameters); this.mappingContext = mappingContext; }
@Override protected Object doExecute(AbstractGqQuery repositoryQuery, Object[] values) { long total = repositoryQuery.getResultCount(values); ParameterAccessor accessor = new ParametersParameterAccessor(parameters, values); Pageable pageable = accessor.getPageable(); if (pageable.getOffset() >= total) { return new PageImpl<Object>(Collections.emptyList(), pageable, total); } List<?> content = repositoryQuery.getResultList(values, pageable); return new PageImpl<>(content, pageable, total); }
/** * Creates a new {@link HazelcastQueryCreator} for the given {@link PartTree} and {@link ParameterAccessor}. The * latter is used to hand actual parameter values into the callback methods as well as to apply dynamic sorting via a * {@link Sort} parameter. * * @param tree must not be {@literal null}. * @param parameters can be {@literal null}. */ public HazelcastQueryCreator(PartTree tree, ParameterAccessor parameters) { super(tree, parameters); if (tree.isLimiting() && tree.getMaxResults() > 0) { this.limit = tree.getMaxResults(); } else { this.limit = 0; } }
@Override public Object execute(Object[] parameters) { ParameterAccessor accessor = new ParametersParameterAccessor(getQueryMethod().getParameters(), parameters); KeyValueQuery<?> query = prepareQuery(parameters); ResultProcessor processor = queryMethod.getResultProcessor().withDynamicProjection(accessor); return processor.processResult(doExecute(parameters, query)); }
/** * Create a {@link KeyValueQuery} given {@link ParameterAccessor}. * * @param accessor must not be {@literal null}. * @return the {@link KeyValueQuery}. */ public KeyValueQuery<?> createQuery(ParameterAccessor accessor) { PartTree tree = new PartTree(getQueryMethod().getName(), getQueryMethod().getEntityInformation().getJavaType()); AbstractQueryCreator<? extends KeyValueQuery<?>, ?> queryCreator = queryCreatorFactory.queryCreatorFor(tree, accessor); KeyValueQuery<?> query = queryCreator.createQuery(); if (tree.isLimiting()) { query.setRows(tree.getMaxResults()); } return query; }
@Override public AbstractQueryCreator<KeyValueQuery<?>, ?> queryCreatorFor(PartTree partTree, ParameterAccessor accessor) { Assert.state(constructor != null, () -> String.format("No constructor (PartTree, ParameterAccessor) could be found on type %s!", type)); return (AbstractQueryCreator<KeyValueQuery<?>, ?>) BeanUtils.instantiateClass(constructor, partTree, accessor); }
public AbstractDynamoDBQueryCreator(PartTree tree, ParameterAccessor parameterAccessor, DynamoDBEntityInformation<T, ID> entityMetadata, DynamoDBOperations dynamoDBOperations) { super(tree, parameterAccessor); this.entityMetadata = entityMetadata; this.dynamoDBOperations = dynamoDBOperations; }
public DynamoDBCountQueryCreator(PartTree tree, ParameterAccessor parameterAccessor, DynamoDBEntityInformation<T, ID> entityMetadata, DynamoDBOperations dynamoDBOperations,boolean pageQuery) { super(tree, parameterAccessor, entityMetadata, dynamoDBOperations); this.pageQuery = pageQuery; }
@Override public Object execute(AbstractDynamoDBQuery<T, ID> dynamoDBQuery, Object[] values) { ParameterAccessor accessor = new ParametersParameterAccessor(parameters, values); Pageable pageable = accessor.getPageable(); Query<T> query = dynamoDBQuery.doCreateQueryWithPermissions(values); List<T> results = query.getResultList(); return createPage(results, pageable,dynamoDBQuery,values); }
@Override public Object execute(AbstractDynamoDBQuery<T, ID> dynamoDBQuery, Object[] values) { ParameterAccessor accessor = new ParametersParameterAccessor(parameters, values); Pageable pageable = accessor.getPageable(); Query<T> query = dynamoDBQuery.doCreateQueryWithPermissions(values); List<T> results = query.getResultList(); return createSlice(results, pageable); }
public TarantoolQueryCreator(PartTree tree, ParameterAccessor parameters) { super(tree, parameters); }
public SnowdropQueryCreator(Class<?> entityClass, PartTree tree, ParameterAccessor parameters, MappingContext<?, SnowdropPersistentProperty> context) { super(tree, parameters); this.entityClass = entityClass; this.context = context; }
public GcloudDatastoreQueryCreator(PartTree tree, ParameterAccessor accessor, DatastoreOptions datastoreOptions) { super(tree, accessor); this.datastoreOptions = datastoreOptions; }
public QueryCreator(PartTree tree, ParameterAccessor parameters) { super(tree, parameters); }
@Override public VaultQueryCreator queryCreatorFor(PartTree partTree, ParameterAccessor accessor) { return new VaultQueryCreator(partTree, accessor, mappingContext); }
ConstructorCachingQueryCreatorFactory(Class<? extends AbstractQueryCreator<?, ?>> type) { this.type = type; this.constructor = ClassUtils.getConstructorIfAvailable(type, PartTree.class, ParameterAccessor.class); }
public DynamoDBQueryCreator(PartTree tree, ParameterAccessor parameterAccessor, DynamoDBEntityInformation<T, ID> entityMetadata, DynamoDBOperations dynamoDBOperations) { super(tree, parameterAccessor, entityMetadata, dynamoDBOperations); }
/** * Creates a new {@link SpelQueryCreator} for the given {@link PartTree} and {@link ParameterAccessor}. * * @param tree must not be {@literal null}. * @param parameters must not be {@literal null}. */ public SpelQueryCreator(PartTree tree, ParameterAccessor parameters) { super(tree, parameters); this.expression = toPredicateExpression(tree); }
public RedisQueryCreator(PartTree tree, ParameterAccessor parameters) { super(tree, parameters); }
T queryCreatorFor(PartTree partTree, ParameterAccessor accessor);