@Test public void testFindAllContractsByUser() { User user = userDAO.read(1L); assertEquals(2, contractDAO.findAllContractsByUser(user).size()); user = userDAO.read(2L); assertEquals(0, contractDAO.findAllContractsByUser(user).size()); }
@SuppressWarnings("unchecked") public Collection<Contract> findAllContractsByUser(User user) { Query query = entityManager.createQuery("SELECT distinct(c) FROM " + getEntityClass().getName() + " c" + " LEFT JOIN FETCH c.optionElementSet o" + " LEFT JOIN FETCH c.functionalitySet f" + " LEFT JOIN FETCH c.referentialSet r" + " LEFT JOIN FETCH c.scenarioSet s" + " WHERE c.user = :user"); query.setParameter("user", user); return query.getResultList(); }
ContractDAO extends AbstractJPADAO<Contract, Long> { @SuppressWarnings("unchecked") public Collection<Contract> findAllContractsByUser(User user) { Query query = entityManager.createQuery("SELECT distinct(c) FROM " + getEntityClass().getName() + " c" + " LEFT JOIN FETCH c.optionElementSet o" + " LEFT JOIN FETCH c.functionalitySet f" + " LEFT JOIN FETCH c.referentialSet r" + " LEFT JOIN FETCH c.scenarioSet s" + " WHERE c.user = :user"); query.setParameter("user", user); return query.getResultList(); } }
ContractDAO extends AbstractJPADAO<Contract, Long> { @SuppressWarnings("unchecked") public Collection<Contract> findAllContractsByUser(User user) { Query query = entityManager.createQuery("SELECT distinct(c) FROM " + getEntityClass().getName() + " c" + " LEFT JOIN FETCH c.optionElementSet o" + " LEFT JOIN FETCH c.functionalitySet f" + " LEFT JOIN FETCH c.referentialSet r" + " LEFT JOIN FETCH c.scenarioSet s" + " WHERE c.user = :user"); query.setParameter("user", user); return query.getResultList(); } ContractDAO(); }
ContractDAO extends AbstractJPADAO<Contract, Long> { @SuppressWarnings("unchecked") public Collection<Contract> findAllContractsByUser(User user) { Query query = entityManager.createQuery("SELECT distinct(c) FROM " + getEntityClass().getName() + " c" + " LEFT JOIN FETCH c.optionElementSet o" + " LEFT JOIN FETCH c.functionalitySet f" + " LEFT JOIN FETCH c.referentialSet r" + " LEFT JOIN FETCH c.scenarioSet s" + " WHERE c.user = :user"); query.setParameter("user", user); return query.getResultList(); } ContractDAO(); @SuppressWarnings("unchecked") Collection<Contract> findAllContractsByUser(User user); @Override Contract read(Long id); }
ContractDAO extends AbstractJPADAO<Contract, Long> { @SuppressWarnings("unchecked") public Collection<Contract> findAllContractsByUser(User user) { Query query = entityManager.createQuery("SELECT distinct(c) FROM " + getEntityClass().getName() + " c" + " LEFT JOIN FETCH c.optionElementSet o" + " LEFT JOIN FETCH c.functionalitySet f" + " LEFT JOIN FETCH c.referentialSet r" + " LEFT JOIN FETCH c.scenarioSet s" + " WHERE c.user = :user"); query.setParameter("user", user); return query.getResultList(); } ContractDAO(); @SuppressWarnings("unchecked") Collection<Contract> findAllContractsByUser(User user); @Override Contract read(Long id);  }