
com.github.wenhao.jpa.specification.InSpecification Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jpa-spec Show documentation
Show all versions of jpa-spec Show documentation
A JAP Query By Specification framework.
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