Java Code Examples for javax.persistence.criteria.CriteriaBuilder#between()
The following examples show how to use
javax.persistence.criteria.CriteriaBuilder#between() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseAction.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
private Long countExpiredWorkWorkCompleted(Business business, DateRange dateRange, String applicationId, String processId, List<String> units, String person) throws Exception { EntityManager em = business.entityManagerContainer().get(WorkCompleted.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Long> cq = cb.createQuery(Long.class); Root<WorkCompleted> root = cq.from(WorkCompleted.class); Predicate p = cb.between(root.get(WorkCompleted_.expireTime), dateRange.getStart(), dateRange.getEnd()); p = cb.and(p, cb.equal(root.get(WorkCompleted_.expired), true)); if (!StringUtils.equals(applicationId, StandardJaxrsAction.EMPTY_SYMBOL)) { p = cb.and(p, cb.equal(root.get(WorkCompleted_.application), applicationId)); } if (!StringUtils.equals(processId, StandardJaxrsAction.EMPTY_SYMBOL)) { p = cb.and(p, cb.equal(root.get(WorkCompleted_.process), processId)); } if (ListTools.isNotEmpty(units)) { p = cb.and(p, root.get(WorkCompleted_.creatorUnit).in(units)); } if (!StringUtils.equals(person, StandardJaxrsAction.EMPTY_SYMBOL)) { p = cb.and(p, cb.equal(root.get(WorkCompleted_.creatorPerson), person)); } cq.select(cb.count(root)).where(p); return em.createQuery(cq).getSingleResult(); }
Example 2
Source File: DingdingAttendanceFactory.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public Long dingdingUnitForDayTimeResultCount(String date, String unit, String timeresult) throws Exception { Date startTime = DateTools.parse(date); startTime = startOneDate(startTime); Date endTime = endOneDate(startTime); EntityManager em = this.entityManagerContainer().get(AttendanceDingtalkDetail.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Long> query = cb.createQuery(Long.class); Root<AttendanceDingtalkDetail> root = query.from(AttendanceDingtalkDetail.class); Predicate p = null; long start = startTime.getTime(); long end = endTime.getTime(); p = cb.between(root.get(AttendanceDingtalkDetail_.userCheckTime), start, end); p = cb.and(p, cb.equal(root.get(AttendanceDingtalkDetail_.o2Unit), unit)); p = cb.and(p, cb.equal(root.get(AttendanceDingtalkDetail_.timeResult), timeresult)); query.select(cb.count(root)).where(p); return em.createQuery(query).getSingleResult(); }
Example 3
Source File: TimerStartTaskUnitStubs.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
private Collection<String> listUnitFromTaskCompleted(Business business, DateRange dateRange) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(TaskCompleted.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<TaskCompleted> root = cq.from(TaskCompleted.class); Predicate p = cb.between(root.get(TaskCompleted_.startTime), dateRange.getStart(), dateRange.getEnd()); cq.select(root.get(TaskCompleted_.unit)).distinct(true).where(p); List<String> list = em.createQuery(cq).getResultList(); return list; }
Example 4
Source File: BaseAction.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
private Long countStartWorkWork(Business business, DateRange dateRange, String applicationId, String processId, List<String> units, String person) throws Exception { EntityManager em = business.entityManagerContainer().get(Work.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Long> cq = cb.createQuery(Long.class); Root<Work> root = cq.from(Work.class); Predicate p = cb.between(root.get(Work_.startTime), dateRange.getStart(), dateRange.getEnd()); if (!StringUtils.equals(applicationId, StandardJaxrsAction.EMPTY_SYMBOL)) { p = cb.and(p, cb.equal(root.get(Work_.application), applicationId)); } if (!StringUtils.equals(processId, StandardJaxrsAction.EMPTY_SYMBOL)) { p = cb.and(p, cb.equal(root.get(Work_.process), processId)); } if (ListTools.isNotEmpty(units)) { p = cb.and(p, root.get(Work_.creatorUnit).in(units)); } if (!StringUtils.equals(person, StandardJaxrsAction.EMPTY_SYMBOL)) { p = cb.and(p, cb.equal(root.get(Work_.creatorPerson), person)); } cq.select(cb.count(root)).where(p); return em.createQuery(cq).getSingleResult(); }
Example 5
Source File: TimerExpiredTaskApplicationStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private String getActivityNameFromTask(Business business, DateRange dateRange, String activityId) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(Task.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<Task> root = cq.from(Task.class); Predicate p = cb.between(root.get(Task_.expireTime), dateRange.getStart(), dateRange.getEnd()); p = cb.and(p, cb.equal(root.get(Task_.activity), activityId)); cq.select(root.get(Task_.activityName)).where(p); List<String> list = em.createQuery(cq).setMaxResults(1).getResultList(); return list.isEmpty() ? null : list.get(0); }
Example 6
Source File: TimerCompletedTaskApplicationStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private String getProcessNameFromTaskCompleted(Business business, DateRange dateRange, String processId) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(TaskCompleted.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<TaskCompleted> root = cq.from(TaskCompleted.class); Predicate p = cb.between(root.get(TaskCompleted_.completedTime), dateRange.getStart(), dateRange.getEnd()); p = cb.and(p, cb.equal(root.get(TaskCompleted_.process), processId)); cq.select(root.get(TaskCompleted_.processName)).where(p); List<String> list = em.createQuery(cq).setMaxResults(1).getResultList(); return list.isEmpty() ? null : list.get(0); }
Example 7
Source File: TimerStartWorkApplicationStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private Collection<String> listApplicationFromWorkCompleted(Business business, DateRange dateRange) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(WorkCompleted.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<WorkCompleted> root = cq.from(WorkCompleted.class); Predicate p = cb.between(root.get(WorkCompleted_.startTime), dateRange.getStart(), dateRange.getEnd()); cq.select(root.get(WorkCompleted_.application)).distinct(true).where(p); List<String> list = em.createQuery(cq).getResultList(); return list; }
Example 8
Source File: TimerExpiredTaskUnitStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private Collection<String> listUnitFromTask(Business business, DateRange dateRange) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(Task.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<Task> root = cq.from(Task.class); Predicate p = cb.between(root.get(Task_.expireTime), dateRange.getStart(), dateRange.getEnd()); cq.select(root.get(Task_.unit)).distinct(true).where(p); List<String> list = em.createQuery(cq).getResultList(); return list; }
Example 9
Source File: DingdingAttendanceFactory.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public Long dingdingPersonForMonthTimeResultCount(String year, String month, String person, String timeresult) throws Exception { Date start = monthFirstDay(year, month); Date end = monthLastDay(year, month); EntityManager em = this.entityManagerContainer().get(AttendanceDingtalkDetail.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Long> query = cb.createQuery(Long.class); Root<AttendanceDingtalkDetail> root = query.from(AttendanceDingtalkDetail.class); Predicate p = cb.between(root.get(AttendanceDingtalkDetail_.userCheckTime), start.getTime(), end.getTime()); p = cb.and(p, cb.equal(root.get(AttendanceDingtalkDetail_.o2User), person)); p = cb.and(p, cb.equal(root.get(AttendanceDingtalkDetail_.timeResult), timeresult)); query.select(cb.count(root)).where(p); return em.createQuery(query).getSingleResult(); }
Example 10
Source File: TimerExpiredWorkUnitStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private Collection<String> listUnitFromWork(Business business, DateRange dateRange) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(Work.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<Work> root = cq.from(Work.class); Predicate p = cb.between(root.get(Work_.expireTime), dateRange.getStart(), dateRange.getEnd()); cq.select(root.get(Work_.creatorUnit)).distinct(true).where(p); List<String> list = em.createQuery(cq).getResultList(); return list; }
Example 11
Source File: TimerExpiredWorkApplicationStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private String getProcessNameFromWork(Business business, DateRange dateRange, String processId) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(Work.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<Work> root = cq.from(Work.class); Predicate p = cb.between(root.get(Work_.expireTime), dateRange.getStart(), dateRange.getEnd()); p = cb.and(p, cb.equal(root.get(Work_.process), processId)); cq.select(root.get(Work_.processName)).where(p); List<String> list = em.createQuery(cq).setMaxResults(1).getResultList(); return list.isEmpty() ? null : list.get(0); }
Example 12
Source File: ByRangeUtil.java From javaee-lab with Apache License 2.0 | 5 votes |
private static <D extends Comparable<? super D>, E> Predicate buildRangePredicate(Range<E, D> range, Root<E> root, CriteriaBuilder builder) { Predicate rangePredicate = null; Path<D> path = JpaUtil.getInstance().getPath(root, range.getAttributes()); if (range.isBetween()) { rangePredicate = builder.between(path, range.getFrom(), range.getTo()); } else if (range.isFromSet()) { rangePredicate = builder.greaterThanOrEqualTo(path, range.getFrom()); } else if (range.isToSet()) { rangePredicate = builder.lessThanOrEqualTo(path, range.getTo()); } if (rangePredicate != null) { if (!range.isIncludeNullSet() || range.getIncludeNull() == FALSE) { return rangePredicate; } else { return builder.or(rangePredicate, builder.isNull(path)); } } else { // no from/to is set, but include null or not could be: if (TRUE == range.getIncludeNull()) { return builder.isNull(path); } else if (FALSE == range.getIncludeNull()) { return builder.isNotNull(path); } } return null; }
Example 13
Source File: TimerExpiredTaskApplicationStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private Collection<String> listActivityFromTask(Business business, DateRange dateRange, ProcessStub processStub) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(Task.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<Task> root = cq.from(Task.class); Predicate p = cb.between(root.get(Task_.expireTime), dateRange.getStart(), dateRange.getEnd()); p = cb.and(p, cb.equal(root.get(Task_.process), processStub.getValue())); cq.select(root.get(Task_.activity)).distinct(true).where(p); List<String> list = em.createQuery(cq).getResultList(); return list; }
Example 14
Source File: TimerStartTaskUnitStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private Collection<String> listUnitFromTask(Business business, DateRange dateRange) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(Task.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<Task> root = cq.from(Task.class); Predicate p = cb.between(root.get(Task_.startTime), dateRange.getStart(), dateRange.getEnd()); cq.select(root.get(Task_.unit)).distinct(true).where(p); List<String> list = em.createQuery(cq).getResultList(); return list; }
Example 15
Source File: AttendanceSelfHolidayFactory.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public List<String> listByStartDateAndEndDate(Date startDate, Date endDate) throws Exception { EntityManager em = this.entityManagerContainer().get(AttendanceSelfHoliday.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<AttendanceSelfHoliday> root = cq.from( AttendanceSelfHoliday.class); Predicate p = cb.between(root.get(AttendanceSelfHoliday_.startTime), startDate, endDate); p = cb.and( p, cb.between(root.get(AttendanceSelfHoliday_.endTime), startDate, endDate)); cq.select(root.get(AttendanceSelfHoliday_.id)); return em.createQuery(cq.where(p)).getResultList(); }
Example 16
Source File: TimerStartTaskApplicationStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private String getActivityNameFromTaskCompleted(Business business, DateRange dateRange, String activityId) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(TaskCompleted.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<TaskCompleted> root = cq.from(TaskCompleted.class); Predicate p = cb.between(root.get(TaskCompleted_.startTime), dateRange.getStart(), dateRange.getEnd()); p = cb.and(p, cb.equal(root.get(TaskCompleted_.activity), activityId)); cq.select(root.get(TaskCompleted_.activityName)).where(p); List<String> list = em.createQuery(cq).setMaxResults(1).getResultList(); return list.isEmpty() ? null : list.get(0); }
Example 17
Source File: TimerExpiredWorkUnitStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private Collection<String> listUnitFromWorkCompleted(Business business, DateRange dateRange) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(WorkCompleted.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<WorkCompleted> root = cq.from(WorkCompleted.class); Predicate p = cb.between(root.get(WorkCompleted_.expireTime), dateRange.getStart(), dateRange.getEnd()); p = cb.and(p, cb.equal(root.get(WorkCompleted_.expired), true)); cq.select(root.get(WorkCompleted_.creatorUnit)).distinct(true).where(p); List<String> list = em.createQuery(cq).getResultList(); return list; }
Example 18
Source File: TimerCompletedTaskUnitStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private Collection<String> listUnitFromTaskCompleted(Business business, DateRange dateRange) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(TaskCompleted.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<TaskCompleted> root = cq.from(TaskCompleted.class); Predicate p = cb.between(root.get(TaskCompleted_.completedTime), dateRange.getStart(), dateRange.getEnd()); cq.select(root.get(TaskCompleted_.unit)).distinct(true).where(p); List<String> list = em.createQuery(cq).getResultList(); return list; }
Example 19
Source File: TimerExpiredTaskApplicationStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private Collection<String> listProcessFromTask(Business business, DateRange dateRange, ApplicationStub applicationStub) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(Task.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<Task> root = cq.from(Task.class); Predicate p = cb.between(root.get(Task_.expireTime), dateRange.getStart(), dateRange.getEnd()); p = cb.and(p, cb.equal(root.get(Task_.application), applicationStub.getValue())); cq.select(root.get(Task_.process)).distinct(true).where(p); List<String> list = em.createQuery(cq).getResultList(); return list; }
Example 20
Source File: TimerStartTaskApplicationStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private Collection<String> listProcessFromTask(Business business, DateRange dateRange, ApplicationStub applicationStub) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(Task.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<Task> root = cq.from(Task.class); Predicate p = cb.between(root.get(Task_.startTime), dateRange.getStart(), dateRange.getEnd()); p = cb.and(p, cb.equal(root.get(Task_.application), applicationStub.getValue())); cq.select(root.get(Task_.process)).distinct(true).where(p); List<String> list = em.createQuery(cq).getResultList(); return list; }