本文整理汇总了Java中javax.persistence.criteria.CriteriaBuilder.greaterThanOrEqualTo方法的典型用法代码示例。如果您正苦于以下问题:Java CriteriaBuilder.greaterThanOrEqualTo方法的具体用法?Java CriteriaBuilder.greaterThanOrEqualTo怎么用?Java CriteriaBuilder.greaterThanOrEqualTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.persistence.criteria.CriteriaBuilder
的用法示例。
在下文中一共展示了CriteriaBuilder.greaterThanOrEqualTo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toPredicate
import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public Predicate toPredicate(Root<?> root, CriteriaQuery<?> query,
CriteriaBuilder builder) {
Path expression = null;
if(fieldName.contains(".")){
String[] names = StringUtils.split(fieldName, ".");
expression = root.get(names[0]);
for (int i = 1; i < names.length; i++) {
expression = expression.get(names[i]);
}
}else{
expression = root.get(fieldName);
}
switch (operator) {
case EQ:
return builder.equal(expression, value);
case NE:
return builder.notEqual(expression, value);
case LIKE:
return builder.like((Expression<String>) expression, "%" + value + "%");
case LT:
return builder.lessThan(expression, (Comparable) value);
case GT:
return builder.greaterThan(expression, (Comparable) value);
case LTE:
return builder.lessThanOrEqualTo(expression, (Comparable) value);
case GTE:
return builder.greaterThanOrEqualTo(expression, (Comparable) value);
default:
return null;
}
}
示例2: findByDateRange
import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
public Collection<EndPointCheck> findByDateRange(final EndPoint endPoint, final Date startDate,
final Date endDate) {
final CriteriaBuilder criteriaBuilder = getEntityManager().getCriteriaBuilder();
final CriteriaQuery<EndPointCheck> criteriaQuery = criteriaBuilder.createQuery(getEntityClass());
final Root<EndPointCheck> root = criteriaQuery
.from(getEntityManager().getMetamodel().entity(getEntityClass()));
final ParameterExpression<EndPoint> endPointParameter = criteriaBuilder.parameter(EndPoint.class);
final ParameterExpression<Date> startDateParameter = criteriaBuilder.parameter(Date.class);
final ParameterExpression<Date> endDateParameter = criteriaBuilder.parameter(Date.class);
final Predicate endPointIdPredicate = criteriaBuilder
.equal(root.get("endPoint"), endPointParameter);
final Path<Date> checkDatePath = root.<Date> get("checkDate");
final Predicate startDatePredicate = criteriaBuilder
.greaterThanOrEqualTo(checkDatePath, startDateParameter);
final Predicate endDatePredicate = criteriaBuilder.lessThanOrEqualTo(
checkDatePath,
endDateParameter);
criteriaQuery.where(criteriaBuilder.and(endPointIdPredicate, startDatePredicate, endDatePredicate));
criteriaQuery.orderBy(Arrays.asList(criteriaBuilder.asc(checkDatePath)));
return getEntityManager().createQuery(criteriaQuery)
.setParameter(endPointParameter, endPoint)
.setParameter(startDateParameter, startDate, TemporalType.DATE)
.setParameter(endDateParameter, endDate, TemporalType.DATE)
.getResultList();
}
示例3: buildJpaPredicate
import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
@SuppressWarnings({ "unchecked" })
public Predicate buildJpaPredicate(CriteriaBuilder cb, Root<?> root) {
Expression<Y> path = QueryFormHelper.getPath(root, field);
Y num = (Y) value;
return cb.greaterThanOrEqualTo(path, num);
}
示例4: buildPredicate
import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@SuppressWarnings ({ "unchecked", "rawtypes" })
protected Predicate buildPredicate(Path<T> root, SearchField field)
{
Path<T> tt = (!field.getField().contains(".")) ? root.get(field.getField()) : fetchNestedPath(root, field.getField());
CriteriaBuilder criteriaBuilder = this.entitymanager.getCriteriaBuilder();
Class<?> javaType = tt.getJavaType();
if (!classCompatibleWithOperator(javaType, field.getOperator()))
{
throw new RuntimeException("operator incompatible with field");
}
Object valueObject = convertStringValueToObject(field.getValue(), javaType);
switch (field.getOperator())
{
case GE:
return criteriaBuilder.greaterThan((Expression) tt, (Comparable) valueObject);
case GTE:
return criteriaBuilder.greaterThanOrEqualTo((Expression) tt, (Comparable) valueObject);
case LE:
return criteriaBuilder.lessThan((Expression) tt, (Comparable) valueObject);
case LTE:
return criteriaBuilder.lessThanOrEqualTo((Expression) tt, (Comparable) valueObject);
case NE:
return criteriaBuilder.notEqual(tt, valueObject);
case EX:
return criteriaBuilder.like((Expression) tt, "%"+field.getValue()+"%");
default:
{
//EQ
return criteriaBuilder.equal(tt, valueObject);
}
}
}
示例5: 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;
}
示例6: toPredicate
import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public Predicate toPredicate(Root<?> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
Path expression = null;
if (fieldName.contains(".")) {
System.out.println(root);
String[] names = StringUtils.split(fieldName, ".");
expression = root.get(names[0]);
for (int i = 1; i < names.length; i++) {
expression = expression.get(names[i]);
}
} else {
expression = root.get(fieldName);
}
switch (operator) {
case EQ:
return builder.equal(expression, value);
case NE:
return builder.notEqual(expression, value);
case LIKE:
return builder.like((Expression<String>) expression, "%" + value + "%");
case RLIKE:
return builder.like((Expression<String>) expression, value + "%");
case LLIKE:
return builder.like((Expression<String>) expression, value + "%");
case LT:
return builder.lessThan(expression, (Comparable) value);
case GT:
return builder.greaterThan(expression, (Comparable) value);
case LTE:
return builder.lessThanOrEqualTo(expression, (Comparable) value);
case GTE:
return builder.greaterThanOrEqualTo(expression, (Comparable) value);
case ISNULL:
return builder.isNull(expression);
case NOTNULL:
return builder.isNotNull(expression);
default:
return null;
}
}
示例7: toPredicate
import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
public Predicate toPredicate(Criterion c, Root<?> r, CriteriaBuilder b) {
return b.greaterThanOrEqualTo(
r.get(c.getPropertyName()), getComparable(c));
}
示例8: toPredicate
import javax.persistence.criteria.CriteriaBuilder; //导入方法依赖的package包/类
@Override
public Predicate toPredicate(final Root<?> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
return cb.greaterThanOrEqualTo(PredicateBuilderUtil.<T>getPath(root, naam), value);
}