Search in sources :

Example 1 with PathImplementor

use of org.hibernate.query.criteria.internal.PathImplementor in project CzechIdMng by bcvsolutions.

the class AbstractReadDtoService method checkFilterSizeExceeded.

/**
 * Check limit of values given for IN predicates.
 *
 * @param predicate start predicate
 * @since 10.6.0
 */
private void checkFilterSizeExceeded(Predicate predicate) {
    if (predicate instanceof InPredicate) {
        InPredicate<?> in = (InPredicate<?>) predicate;
        // common property name => attribute is optional
        String propertyName = "filter";
        if (in.getExpression() instanceof PathImplementor) {
            // TODO: remove root path as 'null', but it is not fit to filter property name anyway => hidden in UI message
            propertyName = ((PathImplementor<?>) in.getExpression()).getPathIdentifier();
        }
        getFilterManager().checkFilterSizeExceeded(new FilterKey(getEntityClass(), propertyName), in.getValues());
    }
    if (predicate instanceof ExistsPredicate) {
        checkFilterSizeExceeded(((ExistsPredicate) predicate).getSubquery().getRestriction());
    }
    predicate.getExpressions().forEach(expression -> {
        if (expression instanceof Predicate) {
            checkFilterSizeExceeded((Predicate) expression);
        }
    });
}
Also used : ExistsPredicate(org.hibernate.query.criteria.internal.predicate.ExistsPredicate) PathImplementor(org.hibernate.query.criteria.internal.PathImplementor) InPredicate(org.hibernate.query.criteria.internal.predicate.InPredicate) FilterKey(eu.bcvsolutions.idm.core.api.repository.filter.FilterKey) Predicate(javax.persistence.criteria.Predicate) InPredicate(org.hibernate.query.criteria.internal.predicate.InPredicate) ExistsPredicate(org.hibernate.query.criteria.internal.predicate.ExistsPredicate)

Aggregations

FilterKey (eu.bcvsolutions.idm.core.api.repository.filter.FilterKey)1 Predicate (javax.persistence.criteria.Predicate)1 PathImplementor (org.hibernate.query.criteria.internal.PathImplementor)1 ExistsPredicate (org.hibernate.query.criteria.internal.predicate.ExistsPredicate)1 InPredicate (org.hibernate.query.criteria.internal.predicate.InPredicate)1