EntityTransaction tx = session.getTransaction();
tx.begin();
CriteriaBuilder cb = session.getCriteriaBuilder();
CriteriaQuery<Appointment> cq = cb.createQuery(Appointment.class);
Root<Appointment> c = cq.from(Appointment.class);
Predicate condition = cb.equal(c.get("deleted"), "false");
Predicate subCondition = cb.equal(c.get("categoryId"), cat_id);
cq.where(condition, subCondition);
TypedQuery<Appointment> q = session.createQuery(cq);
List<Appointment> listAppoints = q.getResultList();
tx.commit();