本文整理汇总了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());
}
示例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;
}
示例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);
}
}
示例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;
}
示例5: CriteriaHolder
import javax.persistence.criteria.CommonAbstractCriteria; //导入依赖的package包/类
public CriteriaHolder(CommonAbstractCriteria query) {
criteriaQuery = query;
setValue(query);
}
示例6: toPredicate
import javax.persistence.criteria.CommonAbstractCriteria; //导入依赖的package包/类
public Predicate toPredicate(CriteriaBuilder builder, CommonAbstractCriteria query, Root<T> root);