List of usage examples for javax.persistence.criteria CriteriaBuilder createQuery
<T> CriteriaQuery<T> createQuery(Class<T> resultClass);
CriteriaQuery
object with the specified result type. From source file:net.groupbuy.dao.impl.FriendLinkDaoImpl.java
public List<FriendLink> findList(Type type) { CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<FriendLink> criteriaQuery = criteriaBuilder.createQuery(FriendLink.class); Root<FriendLink> root = criteriaQuery.from(FriendLink.class); criteriaQuery.select(root);// w w w . ja v a 2 s. c om if (type != null) { criteriaQuery.where(criteriaBuilder.equal(root.get("type"), type)); } criteriaQuery.orderBy(criteriaBuilder.asc(root.get("order"))); return entityManager.createQuery(criteriaQuery).setFlushMode(FlushModeType.COMMIT).getResultList(); }
From source file:net.groupbuy.dao.impl.NavigationDaoImpl.java
public List<Navigation> findList(Position position) { CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<Navigation> criteriaQuery = criteriaBuilder.createQuery(Navigation.class); Root<Navigation> root = criteriaQuery.from(Navigation.class); criteriaQuery.select(root);/*from w w w . j ava 2 s. c om*/ if (position != null) { criteriaQuery.where(criteriaBuilder.equal(root.get("position"), position)); } criteriaQuery.orderBy(criteriaBuilder.asc(root.get("order"))); return entityManager.createQuery(criteriaQuery).setFlushMode(FlushModeType.COMMIT).getResultList(); }
From source file:cz.vse.webmail.EmailDAOBean.java
@Override public List<Email> getFilteredEmails(User user, EmailListFilter filter) { CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery<Email> criteria = cb.createQuery(Email.class); Root<Email> root = criteria.from(Email.class); List<Predicate> predicates = new ArrayList<Predicate>(); predicates.add(cb.equal(root.<User>get("owner"), user)); if (StringUtils.isNoneBlank(filter.getTo())) { predicates.add(cb.like(root.<String>get("to"), "%" + filter.getTo() + "%")); }//from w ww . ja va 2 s . c o m criteria.select(root).where(predicates.toArray(new Predicate[] {})); return entityManager.createQuery(criteria).getResultList(); }
From source file:br.com.compositeam.data.MemberDaoImpl.java
public Member findByEmail(String email) { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Member> criteria = cb.createQuery(Member.class); Root<Member> member = criteria.from(Member.class); /*// www.j a va2 s. c om * Swap criteria statements if you would like to try out type-safe criteria queries, a new * feature in JPA 2.0 criteria.select(member).orderBy(cb.asc(member.get(Member_.name))); */ criteria.select(member).where(cb.equal(member.get("email"), email)); return em.createQuery(criteria).getSingleResult(); }
From source file:br.com.compositeam.data.MemberDaoImpl.java
public List<Member> findAllOrderedByName() { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Member> criteria = cb.createQuery(Member.class); Root<Member> member = criteria.from(Member.class); /*/*from www . j ava 2 s. c om*/ * Swap criteria statements if you would like to try out type-safe criteria queries, a new * feature in JPA 2.0 criteria.select(member).orderBy(cb.asc(member.get(Member_.name))); */ criteria.select(member).orderBy(cb.asc(member.get("name"))); return em.createQuery(criteria).getResultList(); }
From source file:org.oncoblocks.centromere.jpa.test.EntrezGeneRepositoryImpl.java
public List<EntrezGene> guessGene(String keyword) { CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<EntrezGene> query = builder.createQuery(EntrezGene.class); Root<EntrezGene> root = query.from(EntrezGene.class); query.where(builder.equal(root.get("primaryGeneSymbol"), keyword)); List<EntrezGene> genes = entityManager.createQuery(query).getResultList(); if (genes != null && genes.size() > 0) return genes; query = builder.createQuery(EntrezGene.class); root = query.from(EntrezGene.class); Path join = root.join("aliases"); query.where(builder.equal(join.get("name"), keyword)); return entityManager.createQuery(query).getResultList(); }
From source file:net.carinae.dev.async.dao.DummyEntityDaoJPA2.java
@Override public List<DummyEntity> findByData(String data) { // select de from DummyEntity // where de.data = data CriteriaBuilder cb = this.entityManager.getCriteriaBuilder(); CriteriaQuery<DummyEntity> cq = cb.createQuery(DummyEntity.class); Root<DummyEntity> de = cq.from(DummyEntity.class); cq.select(de).where(cb.equal(de.get(DummyEntity_.data), data)); return this.entityManager.createQuery(cq).getResultList(); }
From source file:org.jboss.spring.quickstarts.kitchensink.kitchensink_spring.repo.MemberDaoImpl.java
public Member findByEmail(String email) { CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<Member> criteria = builder.createQuery(Member.class); Root<Member> member = criteria.from(Member.class); /*//from ww w . j a v a 2s .com * Swap criteria statements if you would like to try out type-safe criteria queries, a new * feature in JPA 2.0 criteria.select(member).orderBy(cb.asc(member.get(Member_.name))); */ criteria.select(member).where(builder.equal(member.get("email"), email)); return em.createQuery(criteria).getSingleResult(); }
From source file:$.MemberDaoImpl.java
public Member findByEmail(String email) { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Member> criteria = cb.createQuery(Member.class); Root<Member> member = criteria.from(Member.class); /*/*from w w w. j av a 2 s . co m*/ * Swap criteria statements if you would like to try out type-safe criteria queries, a new * feature in JPA 2.0 criteria.select(member).orderBy(cb.asc(member.get(Member_.name))); */ criteria.select(member).where(cb.equal(member.get("email"), email)); return em.createQuery(criteria).getSingleResult(); }
From source file:$.MemberDaoImpl.java
public List<Member> findAllOrderedByName() { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Member> criteria = cb.createQuery(Member.class); Root<Member> member = criteria.from(Member.class); /*// w w w. j a va 2s. c om * Swap criteria statements if you would like to try out type-safe criteria queries, a new * feature in JPA 2.0 criteria.select(member).orderBy(cb.asc(member.get(Member_.name))); */ criteria.select(member).orderBy(cb.asc(member.get("name"))); return em.createQuery(criteria).getResultList(); }