List of usage examples for javax.persistence.criteria CriteriaBuilder between
<Y extends Comparable<? super Y>> Predicate between(Expression<? extends Y> v, Y x, Y y);
From source file:th.co.geniustree.intenship.advisor.spec.InformationSpec.java
public static Specification<Information> startTimeLike(final Date start, final Date end) { String startTime = Information_.startTime + ""; return new Specification<Information>() { @Override/*from ww w .j a v a 2 s . c o m*/ public Predicate toPredicate(Root<Information> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { return cb.between(root.get(Information_.startTime), start, end); } }; }
From source file:th.co.geniustree.dental.spec.BillSpec.java
public static Specification<Bill> dateBillLike(final Date keyword) { return new Specification<Bill>() { @Override// www .java2 s . co m public Predicate toPredicate(Root<Bill> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { return cb.between(root.get(Bill_.dateBill), keyword, keyword); } }; }
From source file:th.co.geniustree.dental.spec.LotSpec.java
public static Specification<Lot> dateInBetween(final Date keyword) { return new Specification<Lot>() { @Override/*w w w . ja va2s . c o m*/ public Predicate toPredicate(Root<Lot> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { return cb.between(root.get(Lot_.dateIn), keyword, keyword); } }; }
From source file:th.co.geniustree.dental.spec.LotSpec.java
public static Specification<Lot> dateOutBetween(final Date keyword) { return new Specification<Lot>() { @Override/*from w w w . ja v a2s . com*/ public Predicate toPredicate(Root<Lot> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { return cb.between(root.get(Lot_.dateOut), keyword, keyword); } }; }
From source file:th.co.geniustree.dental.spec.AppointmentSpec.java
public static Specification<Appointment> appointmentDate(final Date keyword) { return new Specification<Appointment>() { @Override/*from w w w. j a v a 2 s.co m*/ public Predicate toPredicate(Root<Appointment> root, CriteriaQuery<?> query, CriteriaBuilder cb) { return cb.between(root.get(Appointment_.appointDay), keyword, keyword); } }; }
From source file:th.co.geniustree.dental.spec.DetailHealSpec.java
public static Specification<DetailHeal> dateHealLike(final Date keyword) { return new Specification<DetailHeal>() { @Override/*from w w w . j a v a 2 s . c o m*/ public Predicate toPredicate(Root<DetailHeal> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { return cb.between(root.get(DetailHeal_.dateHeal), keyword, keyword); } }; }
From source file:th.co.geniustree.dental.spec.PriceAndExpireProductSpec.java
public static Specification<PriceAndExpireProduct> expireBetween(final Date keyword) { return new Specification<PriceAndExpireProduct>() { @Override//from ww w. j a va 2 s.c o m public Predicate toPredicate(Root<PriceAndExpireProduct> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { return cb.and(cb.between(root.get(PriceAndExpireProduct_.expire), keyword, keyword), cb.isNull(root.get(PriceAndExpireProduct_.status))); } }; }
From source file:th.co.geniustree.dental.spec.PriceAndExpireProductSpec.java
public static Specification<PriceAndExpireProduct> lotInBetween(final Date keyword) { return new Specification<PriceAndExpireProduct>() { @Override/*from w ww .j a v a 2s . com*/ public Predicate toPredicate(Root<PriceAndExpireProduct> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { return cb.and(cb.between(root.get(PriceAndExpireProduct_.lot).get(Lot_.dateIn), keyword, keyword), cb.isNull(root.get(PriceAndExpireProduct_.status))); } }; }
From source file:th.co.geniustree.dental.spec.DetailHealSpec.java
public static Specification<DetailHeal> dateHealLikeForBill(final Date keyword) { return new Specification<DetailHeal>() { @Override/*from w w w . j a v a 2 s .c o m*/ public Predicate toPredicate(Root<DetailHeal> root, CriteriaQuery<?> cq, CriteriaBuilder cb) { return cb.and(cb.between(root.get(DetailHeal_.dateHeal), keyword, keyword), cb.isNull(root.get(DetailHeal_.status))); } }; }
From source file:net.sf.gazpachoquest.qbe.RangeSpecification.java
public static <E, D extends Comparable<? super D>> Specification<E> toSpecification(final Range<E, D> range) { Validate.isTrue(range.isSet(), "You must pass an exploitable range"); return new Specification<E>() { @Override/*from ww w .ja v a 2s. c o m*/ public Predicate toPredicate(final Root<E> root, final CriteriaQuery<?> query, final CriteriaBuilder builder) { Predicate rangePredicate = null; if (range.isBetween()) { rangePredicate = builder.between(root.get(range.getField()), range.getFrom(), range.getTo()); } else if (range.isFromSet()) { // rangePredicate = // builder.greaterThanOrEqualTo(root.get(range.getField()), // range.getFrom()); rangePredicate = builder.greaterThan(root.get(range.getField()), range.getFrom()); } else if (range.isToSet()) { // rangePredicate = // builder.lessThanOrEqualTo(root.get(range.getField()), // range.getTo()); rangePredicate = builder.lessThan(root.get(range.getField()), range.getTo()); } if (rangePredicate != null) { if (!range.isIncludeNullSet() || Boolean.FALSE.equals(range.getIncludeNull())) { return rangePredicate; } else { return builder.or(rangePredicate, builder.isNull(root.get(range.getField()))); } } // no range at all // take the opportunity to keep only null... if (Boolean.TRUE.equals(range.getIncludeNull())) { return builder.isNull(root.get(range.getField())); } // ... or non-null only... if (Boolean.FALSE.equals(range.getIncludeNull())) { return builder.isNotNull(root.get(range.getField())); } throw new IllegalStateException("You must pass an exploitable range (should not happen here)"); } }; }