1 package de.spring.example.persistence.domain.specifications;
3 import java.time.LocalDate;
5 import javax.persistence.criteria.CriteriaBuilder;
6 import javax.persistence.criteria.CriteriaQuery;
7 import javax.persistence.criteria.Predicate;
8 import javax.persistence.criteria.Root;
10 import org.springframework.data.jpa.domain.Specification;
12 import de.spring.example.persistence.domain.Ad;
14 public class AdSpectifications {
16 public static Specification<Ad> createdToday() {
17 return new Specification<Ad>() {
20 public Predicate toPredicate(Root<Ad> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
21 final LocalDate date = LocalDate.now();
23 return cb.equal(root.get("createdAt"), date);
30 public static Specification<Ad> mobileImage(String image) {
31 return new Specification<Ad>() {
34 public Predicate toPredicate(Root<Ad> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
36 return cb.equal(root.get("adMobileImage"), image);