Examples of CriteriaBuilder


Examples of javax.persistence.criteria.CriteriaBuilder

    try {
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      CriteriaBuilder cb = session.getCriteriaBuilder();
      CriteriaQuery<Rooms> cq = cb.createQuery(Rooms.class);
      TypedQuery<Rooms> q = session.createQuery(cq);
      List<Rooms> ll = q.getResultList();
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
      return ll;
View Full Code Here

Examples of javax.persistence.criteria.CriteriaBuilder

    try {
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      CriteriaBuilder cb = session.getCriteriaBuilder();
      CriteriaQuery<Rooms> cq = cb.createQuery(Rooms.class);
      Root<Rooms> c = cq.from(Rooms.class);
      Predicate condition = cb.equal(c.get("deleted"), "false");
      Predicate subCondition = cb.equal(c.get("externalRoomType"), externalRoomType);
      cq.where(condition, subCondition);
      cq.distinct(asc);
      if (asc){
        cq.orderBy(cb.asc(c.get(orderby)));
      } else {
        cq.orderBy(cb.desc(c.get(orderby)));
      }
      TypedQuery<Rooms> q = session.createQuery(cq);
      q.setFirstResult(start);
      q.setMaxResults(max);
      List<Rooms> ll = q.getResultList();
View Full Code Here

Examples of javax.persistence.criteria.CriteriaBuilder

      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
     
      CriteriaBuilder cb = session.getCriteriaBuilder();
      CriteriaQuery<Rooms_Organisation> cq = cb.createQuery(Rooms_Organisation.class);
      Root<Rooms_Organisation> c = cq.from(Rooms_Organisation.class);
      Predicate condition = cb.equal(c.get("rooms_organisation_id"), rooms_organisation_id);
      cq.where(condition);
      TypedQuery<Rooms_Organisation> q = session.createQuery(cq);
      List<Rooms_Organisation> ll = q.getResultList();
     
      tx.commit();
View Full Code Here

Examples of javax.persistence.criteria.CriteriaBuilder

    try {
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      CriteriaBuilder cb = session.getCriteriaBuilder();
      CriteriaQuery<Rooms_Organisation> cq = cb.createQuery(Rooms_Organisation.class);
      Root<Rooms_Organisation> c = cq.from(Rooms_Organisation.class);
      TypedQuery<Rooms_Organisation> q = session.createQuery(cq);
      List<Rooms_Organisation> ll = q.getResultList();
      tx.commit();
      PersistenceSessionUtil.closeSession(idf);
View Full Code Here

Examples of javax.persistence.criteria.CriteriaBuilder

    try {
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      CriteriaBuilder cb = session.getCriteriaBuilder();
      CriteriaQuery<Organisation> cq = cb.createQuery(Organisation.class);
      Root<Organisation> c = cq.from(Organisation.class);
      Predicate condition = cb.equal(c.get("deleted"), "false");
      cq.where(condition);
      cq.distinct(asc);
      if (asc) {
        cq.orderBy(cb.asc(c.get(orderby)));
      } else {
        cq.orderBy(cb.desc(c.get(orderby)));
      }
      TypedQuery<Organisation> q = session.createQuery(cq);
      q.setFirstResult(start);
      q.setMaxResults(max);
      List<Organisation> ll = q.getResultList();
View Full Code Here

Examples of javax.persistence.criteria.CriteriaBuilder

      if (AuthLevelmanagement.getInstance().checkAdminLevel(user_level)) {
        Object idf = PersistenceSessionUtil.createSession();
        EntityManager session = PersistenceSessionUtil.getSession();
        EntityTransaction tx = session.getTransaction();
        tx.begin();
        CriteriaBuilder cb = session.getCriteriaBuilder();
        CriteriaQuery<Organisation> cq = cb
            .createQuery(Organisation.class);
        Root<Organisation> c = cq.from(Organisation.class);
        Predicate condition = cb.equal(c.get("deleted"), "false");
        cq.where(condition);
        TypedQuery<Organisation> q = session.createQuery(cq);
        List<Organisation> ll = q.getResultList();
        tx.commit();
        PersistenceSessionUtil.closeSession(idf);
View Full Code Here

Examples of javax.persistence.criteria.CriteriaBuilder

    try {
      Object idf = PersistenceSessionUtil.createSession();
      EntityManager session = PersistenceSessionUtil.getSession();
      EntityTransaction tx = session.getTransaction();
      tx.begin();
      CriteriaBuilder cb = session.getCriteriaBuilder();
      CriteriaQuery<LdapConfig> cq = cb.createQuery(LdapConfig.class);
      Root<LdapConfig> c = cq.from(LdapConfig.class);
      Predicate condition = cb.equal(c.get("deleted"), "false");
      cq.where(condition);
      cq.distinct(asc);
      if (asc){
        cq.orderBy(cb.asc(c.get(orderby)));
      } else {
        cq.orderBy(cb.desc(c.get(orderby)));
      }
      TypedQuery<LdapConfig> q = session.createQuery(cq);
      q.setFirstResult(start);
      q.setMaxResults(max);
      List<LdapConfig> ll = q.getResultList();
View Full Code Here

Examples of javax.persistence.criteria.CriteriaBuilder

  public void createPerson(Person person) {
    entityManager.persist( person );
  }

  public List<Person> findPersons() {
    CriteriaBuilder builder = entityManager.getCriteriaBuilder();
    CriteriaQuery<Person> criteriaQuery = builder.createQuery( Person.class );
    criteriaQuery.select( criteriaQuery.from( Person.class ) );
    List<Person> persons = entityManager.createQuery( criteriaQuery ).getResultList();
    return persons;
  }
View Full Code Here

Examples of javax.persistence.criteria.CriteriaBuilder

    protected Object lookupIdentity(IdentityObject obj, EntityManager em) {
        Property<?> identityNameProp = modelProperties.get(PROPERTY_IDENTITY_NAME);
        Property<?> identityTypeProp = modelProperties.get(PROPERTY_IDENTITY_TYPE);

        CriteriaBuilder builder = em.getCriteriaBuilder();
        CriteriaQuery<?> criteria = builder.createQuery(identityClass);
        Root<?> root = criteria.from(identityClass);

        List<Predicate> predicates = new ArrayList<Predicate>();
        predicates.add(builder.equal(root.get(identityNameProp.getName()), obj.getName()));
        predicates.add(builder.equal(root.get(identityTypeProp.getName()), lookupIdentityType(obj.getIdentityType().getName(), em)));

        // TODO add criteria for identity type

        criteria.where(predicates.toArray(new Predicate[predicates.size()]));
View Full Code Here

Examples of javax.persistence.criteria.CriteriaBuilder

    }

    protected Object lookupCredentialTypeEntity(String name, EntityManager em) {
        Property<?> credentialTypeNameProp = modelProperties.get(PROPERTY_CREDENTIAL_TYPE_NAME);

        CriteriaBuilder builder = em.getCriteriaBuilder();
        CriteriaQuery<?> criteria = builder.createQuery(credentialTypeNameProp.getDeclaringClass());
        Root<?> root = criteria.from(credentialTypeNameProp.getDeclaringClass());

        List<Predicate> predicates = new ArrayList<Predicate>();
        predicates.add(builder.equal(root.get(credentialTypeNameProp.getName()), name));
        criteria.where(predicates.toArray(new Predicate[predicates.size()]));

        return em.createQuery(criteria).getSingleResult();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.