本文整理汇总了Java中javax.persistence.criteria.CriteriaBuilder.between方法的典型用法代码示例。如果您正苦于以下问题:Java CriteriaBuilder.between方法的具体用法?Java CriteriaBuilder.between怎么用?Java CriteriaBuilder.between使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.persistence.criteria.CriteriaBuilder
的用法示例。
在下文中一共展示了CriteriaBuilder.between方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildJpaPredicate
import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public Predicate buildJpaPredicate(CriteriaBuilder cb, Root root) {
String field1 = (String) Array.get(value, 0);
String field2 = (String) Array.get(value, 1);
Expression<Comparable> path1 = QueryFormHelper.getPath(root, field1);
Expression<Comparable> path2 = QueryFormHelper.getPath(root, field2);
Expression<Comparable> parameter = cb.literal((Comparable) value);
return cb.between(parameter, path1, path2);
}
示例2: buildJpaPredicate
import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public Predicate buildJpaPredicate(CriteriaBuilder builder, Root root) {
Expression<Comparable> path = QueryFormHelper.getPath(root, field);
Comparable value1 = (Comparable) Array.get(value, 0);
Comparable value2 = (Comparable) Array.get(value, 1);
return builder.between(path, value1, value2);
}
示例3: buildRangePredicate
import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
private Predicate buildRangePredicate(Range<T> range, Root<T> root, CriteriaBuilder builder) {
if (range.isBetween()) {
return builder.between(root.get(range.getField()), range.getFrom(), range.getTo());
} else if (range.isFromSet()) {
return builder.greaterThanOrEqualTo(root.get(range.getField()), range.getFrom());
} else if (range.isToSet()) {
return builder.lessThanOrEqualTo(root.get(range.getField()), range.getTo());
}
return null;
}