Java Code Examples for org.springframework.data.repository.query.parser.PartTree#isLimiting()
The following examples show how to use
org.springframework.data.repository.query.parser.PartTree#isLimiting() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CypherQueryCreator.java From sdn-rx with Apache License 2.0 | 5 votes |
CypherQueryCreator(Neo4jMappingContext mappingContext, Class<?> domainType, Neo4jQueryType queryType, PartTree tree, ParametersParameterAccessor actualParameters, List<String> includedProperties, Function<Object, Object> parameterConversion ) { super(tree, actualParameters); this.mappingContext = mappingContext; this.domainType = domainType; this.nodeDescription = this.mappingContext.getRequiredNodeDescription(this.domainType); this.queryType = queryType; this.formalParameters = actualParameters.getParameters().iterator(); this.maxResults = tree.isLimiting() ? tree.getMaxResults() : null; this.includedProperties = includedProperties; this.parameterConversion = parameterConversion; this.pagingParameter = actualParameters.getPageable(); AtomicInteger symbolicNameIndex = new AtomicInteger(); propertyPathWrappers = tree.getParts().stream() .map(part -> new PropertyPathWrapper(symbolicNameIndex.getAndIncrement(), mappingContext.getPersistentPropertyPath(part.getProperty()))) .collect(toList()); }
Example 2
Source File: SpannerStatementQueryExecutor.java From spring-cloud-gcp with Apache License 2.0 | 5 votes |
private static void buildLimit(PartTree tree, StringBuilder stringBuilder, Pageable pageable) { if (tree.isExistsProjection()) { stringBuilder.append(" LIMIT 1"); } else if (pageable.isPaged()) { stringBuilder.append(" LIMIT ").append(pageable.getPageSize()) .append(" OFFSET ").append(pageable.getOffset()); } else if (tree.isLimiting()) { stringBuilder.append(" LIMIT ").append(tree.getMaxResults()); } }
Example 3
Source File: HazelcastQueryCreator.java From spring-data-hazelcast with Apache License 2.0 | 5 votes |
/** * Creates a new {@link HazelcastQueryCreator} for the given {@link PartTree}. * * @param tree must not be {@literal null}. */ public HazelcastQueryCreator(PartTree tree) { super(tree); final Integer maxResults = tree.getMaxResults(); if (tree.isLimiting() && maxResults != null && maxResults > 0) { this.limit = maxResults; } else { this.limit = 0; } }
Example 4
Source File: HazelcastQueryCreator.java From spring-data-hazelcast with Apache License 2.0 | 5 votes |
/** * 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); final Integer maxResults = tree.getMaxResults(); if (tree.isLimiting() && maxResults != null && maxResults > 0) { this.limit = maxResults; } else { this.limit = 0; } }
Example 5
Source File: KeyValuePartTreeQuery.java From spring-data-keyvalue with Apache License 2.0 | 5 votes |
/** * 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; }
Example 6
Source File: IgniteQueryGenerator.java From ignite with Apache License 2.0 | 4 votes |
/** * @param mtd Method. * @param metadata Metadata. */ @NotNull public static IgniteQuery generateSql(Method mtd, RepositoryMetadata metadata) { PartTree parts = new PartTree(mtd.getName(), metadata.getDomainType()); StringBuilder sql = new StringBuilder(); if (parts.isDelete()) throw new UnsupportedOperationException("DELETE clause is not supported now."); else { sql.append("SELECT "); if (parts.isDistinct()) throw new UnsupportedOperationException("DISTINCT clause in not supported."); if (parts.isCountProjection()) sql.append("COUNT(1) "); else sql.append(" * "); } sql.append("FROM ").append(metadata.getDomainType().getSimpleName()); if (parts.iterator().hasNext()) { sql.append(" WHERE "); for (PartTree.OrPart orPart : parts) { sql.append("("); for (Part part : orPart) { handleQueryPart(sql, part); sql.append(" AND "); } sql.delete(sql.length() - 5, sql.length()); sql.append(") OR "); } sql.delete(sql.length() - 4, sql.length()); } addSorting(sql, parts.getSort()); if (parts.isLimiting()) { sql.append(" LIMIT "); sql.append(parts.getMaxResults().intValue()); } return new IgniteQuery(sql.toString(), parts.isCountProjection(), getOptions(mtd)); }
Example 7
Source File: IgniteQueryGenerator.java From ignite with Apache License 2.0 | 4 votes |
/** * @param mtd Method. * @param metadata Metadata. * @return Generated ignite query. */ public static IgniteQuery generateSql(Method mtd, RepositoryMetadata metadata) { PartTree parts = new PartTree(mtd.getName(), metadata.getDomainType()); boolean isCountOrFieldQuery = parts.isCountProjection(); StringBuilder sql = new StringBuilder(); if (parts.isDelete()) { sql.append("DELETE "); // For the DML queries aside from SELECT *, they should run over SqlFieldQuery isCountOrFieldQuery = true; } else { sql.append("SELECT "); if (parts.isDistinct()) throw new UnsupportedOperationException("DISTINCT clause in not supported."); if (isCountOrFieldQuery) sql.append("COUNT(1) "); else sql.append("* "); } sql.append("FROM ").append(metadata.getDomainType().getSimpleName()); if (parts.iterator().hasNext()) { sql.append(" WHERE "); for (PartTree.OrPart orPart : parts) { sql.append("("); for (Part part : orPart) { handleQueryPart(sql, part); sql.append(" AND "); } sql.delete(sql.length() - 5, sql.length()); sql.append(") OR "); } sql.delete(sql.length() - 4, sql.length()); } addSorting(sql, parts.getSort()); if (parts.isLimiting()) { sql.append(" LIMIT "); sql.append(parts.getMaxResults().intValue()); } return new IgniteQuery(sql.toString(), isCountOrFieldQuery, false, true, getOptions(mtd)); }
Example 8
Source File: IgniteQueryGenerator.java From ignite with Apache License 2.0 | 4 votes |
/** * @param mtd Method. * @param metadata Metadata. * @return Generated ignite query. */ public static IgniteQuery generateSql(Method mtd, RepositoryMetadata metadata) { PartTree parts = new PartTree(mtd.getName(), metadata.getDomainType()); boolean isCountOrFieldQuery = parts.isCountProjection(); StringBuilder sql = new StringBuilder(); if (parts.isDelete()) { sql.append("DELETE "); // For the DML queries aside from SELECT *, they should run over SqlFieldQuery isCountOrFieldQuery = true; } else { sql.append("SELECT "); if (parts.isDistinct()) throw new UnsupportedOperationException("DISTINCT clause in not supported."); if (isCountOrFieldQuery) sql.append("COUNT(1) "); else sql.append("* "); } sql.append("FROM ").append(metadata.getDomainType().getSimpleName()); if (parts.iterator().hasNext()) { sql.append(" WHERE "); for (PartTree.OrPart orPart : parts) { sql.append("("); for (Part part : orPart) { handleQueryPart(sql, part); sql.append(" AND "); } sql.delete(sql.length() - 5, sql.length()); sql.append(") OR "); } sql.delete(sql.length() - 4, sql.length()); } addSorting(sql, parts.getSort()); if (parts.isLimiting()) { sql.append(" LIMIT "); sql.append(parts.getMaxResults().intValue()); } return new IgniteQuery(sql.toString(), isCountOrFieldQuery, false, true, getOptions(mtd)); }