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

com.github.wenhao.jpa.specification.InSpecification Maven / Gradle / Ivy

The newest version!
package com.github.wenhao.jpa.specification;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.From;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

public class InSpecification extends AbstractSpecification {
    private String property;
    private Object[] values;

    public InSpecification(String property, Object[] values) {
        this.property = property;
        this.values = values;
    }

    @Override
    public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder cb) {
        From from = getRoot(property, root);
        String field = getProperty(property);
        return from.get(field).in(values);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy