Example usage for javax.persistence.criteria Root get

List of usage examples for javax.persistence.criteria Root get

Introduction

In this page you can find the example usage for javax.persistence.criteria Root get.

Prototype

<Y> Path<Y> get(SingularAttribute<? super X, Y> attribute);

Source Link

Document

Create a path corresponding to the referenced single-valued attribute.

Usage

From source file:org.ngrinder.agent.repository.AgentManagerSpecification.java

/**
 * Query specification to query the visible agents. "visible" means.. it's
 * visible by the agent monitor.//w  ww  . ja v  a  2  s  .co m
 *
 * @return Specification of this query
 */
public static Specification<AgentInfo> visible() {
    return new Specification<AgentInfo>() {
        @Override
        public Predicate toPredicate(Root<AgentInfo> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
            Expression<AgentControllerState> status = root.get("state").as(AgentControllerState.class);
            return cb.notEqual(status, AgentControllerState.INACTIVE);
        }
    };
}

From source file:org.ngrinder.agent.repository.AgentManagerSpecification.java

/**
 * Query specification to query the active agents.
 *
 * @return Specification of this query//from   w  ww .  j  ava2 s .  c  o  m
 */
public static Specification<AgentInfo> active() {
    return new Specification<AgentInfo>() {
        @Override
        public Predicate toPredicate(Root<AgentInfo> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
            Expression<AgentControllerState> status = root.get("state").as(AgentControllerState.class);
            return cb.and(cb.notEqual(status, AgentControllerState.INACTIVE),
                    cb.notEqual(status, AgentControllerState.UNKNOWN),
                    cb.notEqual(status, AgentControllerState.WRONG_REGION));
        }
    };
}

From source file:th.co.geniustree.dental.spec.AppointmentSpec.java

public static Specification<Appointment> nameDoctorLike(final String keyword) {
    return new Specification<Appointment>() {

        @Override/*w ww  . j a va  2s .  c  om*/
        public Predicate toPredicate(Root<Appointment> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
            return cb.or(
                    cb.like(cb.upper(root.get(Appointment_.doctor).get(Doctor_.nameEng)),
                            keyword.toUpperCase()),
                    cb.like(root.get(Appointment_.doctor).get(Doctor_.nameTh), 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   www.  java2s .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 ww  w .  j a  v a  2  s .c  om
        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:edu.pitt.dbmi.ccd.db.specification.AnnotationTargetSpecification.java

private static Predicate isFile(Root<AnnotationTarget> root, CriteriaBuilder cb) {
    return cb.isNull(root.get(ADDRESS));
}

From source file:th.co.geniustree.dental.spec.PriceAndExpireProductSpec.java

public static Specification<PriceAndExpireProduct> productLike(final String keyword) {
    return new Specification<PriceAndExpireProduct>() {

        @Override// w w w.  j  av  a 2  s  . c  om
        public Predicate toPredicate(Root<PriceAndExpireProduct> root, CriteriaQuery<?> cq,
                CriteriaBuilder cb) {
            return cb.and(cb.like(cb.upper(root.get(PriceAndExpireProduct_.product).get(Product_.name)),
                    keyword.toUpperCase()), cb.isNull(root.get(PriceAndExpireProduct_.status)));
        }
    };
}

From source file:edu.pitt.dbmi.ccd.db.specification.AnnotationTargetSpecification.java

private static Predicate isURL(Root<AnnotationTarget> root, CriteriaBuilder cb) {
    return cb.isNotNull(root.get(ADDRESS));
}

From source file:com.mtt.myapp.user.repository.UserSpecification.java

/**
 * Create "Email like" query spec.//from  www .  j a va2 s. c om
 * @param query query
 * @return created spec
 */
public static Specification<User> emailLike(final String query) {
    return new Specification<User>() {
        @Override
        public Predicate toPredicate(Root<User> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
            String pattern = ("%" + query + "%").toLowerCase();
            return cb.like(cb.lower(root.get("email").as(String.class)), pattern);
        }
    };
}

From source file:edu.pitt.dbmi.ccd.db.specification.AnnotationTargetSpecification.java

private static Predicate titleContains(Root<AnnotationTarget> root, CriteriaBuilder cb, String term) {
    return cb.like(cb.lower(root.get(TITLE)), term);
}