當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。