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


Java CommonAbstractCriteria类代码示例

本文整理汇总了Java中javax.persistence.criteria.CommonAbstractCriteria的典型用法代码示例。如果您正苦于以下问题:Java CommonAbstractCriteria类的具体用法?Java CommonAbstractCriteria怎么用?Java CommonAbstractCriteria使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CommonAbstractCriteria类属于javax.persistence.criteria包,在下文中一共展示了CommonAbstractCriteria类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: filterQuery

import javax.persistence.criteria.CommonAbstractCriteria; //导入依赖的package包/类
private <Q extends CommonAbstractCriteria> FilterResult<Q> filterQuery(Q query, Root<?> root) {
    Map<Path, Class<?>> selectedTypes = new HashMap<Path, Class<?>>();
    Path path = getSelectedPath(0, root);
    selectedTypes.put(path, root.getJavaType());
    AccessDefinition accessDefinition = createAccessDefinition(
            selectedTypes,
            AccessType.READ,
            root.getAlias() != null? singleton(new Alias(root.getAlias())): Collections.<Alias>emptySet());
    FilterResult<Q> filterResult
        = getAlwaysEvaluatableResult(new JpqlCompiledStatement(null), query, accessDefinition);
    if (filterResult != null) {
        return filterResult;
    }
    optimize(accessDefinition);
    Set<String> parameterNames = compiler.getNamedParameters(accessDefinition.getAccessRules());
    Map<String, Object> parameters = accessDefinition.getQueryParameters();
    parameters.keySet().retainAll(parameterNames);

    CriteriaHolder criteriaHolder = new CriteriaHolder(query);
    getQueryPreparator().createWhere(accessDefinition.getAccessRules()).visit(criteriaVisitor, criteriaHolder);
    return new CriteriaFilterResult<Q>(
            query, parameters.size() > 0? parameters: null, criteriaHolder.getParameters());
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:24,代码来源:CriteriaEntityFilter.java

示例2: createQuery

import javax.persistence.criteria.CommonAbstractCriteria; //导入依赖的package包/类
private <C extends CommonAbstractCriteria, Q extends Query> Q createQuery(Q query, FilterResult<C> filterResult) {
    Q secureQuery = (Q)new SecureQuery(query,
            null, // TODO how to extract this?
            filterResult.getSelectedPaths(),
            super.getFlushMode());
    if (filterResult.getParameters() != null && filterResult instanceof CriteriaFilterResult) {
        CriteriaFilterResult<C> criteriaResult = (CriteriaFilterResult<C>)filterResult;
        for (Parameter<?> parameter: criteriaResult.getCriteriaParameters()) {
            Object value = filterResult.getParameters().get(parameter.getName());
            secureQuery.setParameter((Parameter<Object>)parameter, value);
        }
    }
    return secureQuery;
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:15,代码来源:DefaultSecureEntityManager.java

示例3: getFrom

import javax.persistence.criteria.CommonAbstractCriteria; //导入依赖的package包/类
private From<?, ?> getFrom(CommonAbstractCriteria query, Alias alias) {
    if (query instanceof CriteriaUpdate) {
        return ((CriteriaUpdate<?>)query).getRoot();
    } else if (query instanceof CriteriaDelete) {
        return ((CriteriaUpdate<?>)query).getRoot();
    } else {
        return getFrom((AbstractQuery<?>)query, alias);
    }
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:10,代码来源:CriteriaHolder.java

示例4: buildQuery

import javax.persistence.criteria.CommonAbstractCriteria; //导入依赖的package包/类
@Nullable
private <U, V extends CommonAbstractCriteria, W extends Query> W buildQuery(EntityManager entityManager, BiFunction<EntityManager, V, W> queryBuilder,
    V criteriaQuery, BiFunction<V, Predicate[], V> whereBuilder, Root<T> root, @Nullable Integer maxResults) {
    Predicate predicate = null;

    if (this.hasKeywords()) {
        Long[] fullTextEntityIds = this.processKeywords(entityManager, maxResults);

        if (ArrayUtils.isEmpty(fullTextEntityIds)) {
            return null;
        }

        Path<BigInteger> fullTextEntityIdPath = root.get(DbPropertyNames.ENTITY_ID);

        predicate = ((fullTextEntityIds.length == 1)
            ? this.criteriaBuilder.equal(fullTextEntityIdPath, fullTextEntityIds[0])
            : this.criteriaBuilder.in(fullTextEntityIdPath).in(((Object[]) fullTextEntityIds)));

        maxResults = ((maxResults != null) ? Math.min(maxResults, fullTextEntityIds.length) : fullTextEntityIds.length);
    }

    if (this.hasCriterions()) {
        Predicate criterionsPredicate = this.criteriaBuilder
            .and(this.criterions.stream().map(criterion -> criterion.toPredicate(this.criteriaBuilder, criteriaQuery, root)).toArray(Predicate[]::new));

        predicate = ((predicate != null) ? this.criteriaBuilder.and(predicate, criterionsPredicate) : criterionsPredicate);
    }

    if (predicate != null) {
        whereBuilder.apply(criteriaQuery, ArrayUtils.toArray(predicate));
    }

    W query = queryBuilder.apply(entityManager, criteriaQuery);

    if (maxResults != null) {
        query.setMaxResults(maxResults);
    }

    return query;
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:41,代码来源:SdcctCriteriaImpl.java

示例5: CriteriaHolder

import javax.persistence.criteria.CommonAbstractCriteria; //导入依赖的package包/类
public CriteriaHolder(CommonAbstractCriteria query) {
    criteriaQuery = query;
    setValue(query);
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:5,代码来源:CriteriaHolder.java

示例6: toPredicate

import javax.persistence.criteria.CommonAbstractCriteria; //导入依赖的package包/类
public Predicate toPredicate(CriteriaBuilder builder, CommonAbstractCriteria query, Root<T> root); 
开发者ID:esacinc,项目名称:sdcct,代码行数:2,代码来源:SdcctCriterion.java


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