All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.blinkfox.fenix.specification.handler.impl.OrInPredicateHandler Maven / Gradle / Ivy

Go to download

This is an extension library to the Spring Data JPA complex or dynamic SQL query. 这是一个为了解决复杂动态 SQL (JPQL) 而生的 Spring Data JPA 扩展库,能辅助开发者更方便快捷的书写复杂、动态且易于维护的 SQL,支持 ActiveRecord 模式和多种查询方式。

There is a newer version: 3.0.0
Show newest version
package com.blinkfox.fenix.specification.handler.impl;

import com.blinkfox.fenix.specification.annotation.OrIn;
import com.blinkfox.fenix.specification.handler.AbstractPredicateHandler;
import java.lang.annotation.Annotation;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.From;
import javax.persistence.criteria.Predicate;

/**
 * 构建“或者范围匹配条件”({@code OR field IN ('xxx', 'yyy')})场景的 {@link Predicate} 处理器.
 *
 * @author YangWenpeng on 2019-12-17
 * @author blinkfox on 2020-01-14
 * @since v2.2.0
 */
public class OrInPredicateHandler extends AbstractPredicateHandler {

    @Override
    public Class getAnnotation() {
        return OrIn.class;
    }

    @Override
    public  Predicate buildPredicate(
            CriteriaBuilder criteriaBuilder, From from, String fieldName, Object value, Annotation annotation) {
        return criteriaBuilder.or(
                super.buildInPredicate(criteriaBuilder, from, fieldName, value, super.isAllowNull(annotation)));
    }

    @Override
    public Predicate buildPredicate(
            CriteriaBuilder criteriaBuilder, From from, String fieldName, Object value) {
        return criteriaBuilder.or(super.buildInPredicate(criteriaBuilder, from, fieldName, value, false));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy