use of fi.otavanopisto.muikku.plugins.communicator.model.CommunicatorMessageRecipient in project muikku by otavanopisto.
the class CommunicatorMessageRecipientUserGroupDAO method listByMessage.
public List<CommunicatorMessageRecipientUserGroup> listByMessage(CommunicatorMessage communicatorMessage) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<CommunicatorMessageRecipientUserGroup> criteria = criteriaBuilder.createQuery(CommunicatorMessageRecipientUserGroup.class);
Root<CommunicatorMessageRecipientUserGroup> root = criteria.from(CommunicatorMessageRecipientUserGroup.class);
Root<CommunicatorMessageRecipient> root2 = criteria.from(CommunicatorMessageRecipient.class);
criteria.select(root).distinct(true);
criteria.where(criteriaBuilder.and(root2.get(CommunicatorMessageRecipient_.recipientGroup).in(root), criteriaBuilder.equal(root2.get(CommunicatorMessageRecipient_.communicatorMessage), communicatorMessage)));
return entityManager.createQuery(criteria).getResultList();
}
Aggregations