传入一个开始时间(beginDate)以及结束时间(endDate)与某个时间(someTime)进行比较:


restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.greaterThanOrEqualTo(root. get("someTime"), beginDate));


restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.lessThanOrEqualTo(root. get("someTime"), endDate));


其实就是两个方法不一样:大于用greaterThanOrEqualTo(...)和小于用lessThanOrEqualTo(...)