@Test public void testRead() { Contract contract = contractDAO.read(1L); assertNotNull(contract); assertEquals("http: assertEquals(Long.valueOf("1"), contract.getUser().getId()); Set<String> functionalityCodeSet = new HashSet<>(); for (Functionality functionality : contract.getFunctionalitySet()) { functionalityCodeSet.add(functionality.getCode()); } assertTrue(functionalityCodeSet.contains("PAGES_AUDIT")); assertTrue(!functionalityCodeSet.contains("SITE_AUDIT")); assertEquals(1, contract.getReferentialSet().size()); assertTrue(contract.getScenarioSet().isEmpty()); contract = contractDAO.read(2L); assertNotNull(contract); assertEquals("http: assertEquals(Long.valueOf("1"), contract.getUser().getId()); functionalityCodeSet = new HashSet<>(); for (Functionality functionality : contract.getFunctionalitySet()) { functionalityCodeSet.add(functionality.getCode()); } assertTrue(functionalityCodeSet.contains("PAGES_AUDIT")); assertTrue(functionalityCodeSet.contains("SITE_AUDIT")); assertEquals(2, contract.getReferentialSet().size()); assertEquals(2, contract.getScenarioSet().size()); contract = contractDAO.read(Long.valueOf(3)); assertNull(contract); }
@Override public Contract read(Long id) { try { Query query = entityManager.createQuery("SELECT 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.id = :id"); query.setParameter("id", id); Contract contract = (Contract) query.getSingleResult(); contract.getOptionElementSet().size(); contract.getFunctionalitySet().size(); contract.getScenarioSet().size(); contract.getReferentialSet().size(); return contract; } catch (NoResultException nre) { return null; } }
ContractDAO extends AbstractJPADAO<Contract, Long> { @Override public Contract read(Long id) { try { Query query = entityManager.createQuery("SELECT 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.id = :id"); query.setParameter("id", id); Contract contract = (Contract) query.getSingleResult(); contract.getOptionElementSet().size(); contract.getFunctionalitySet().size(); contract.getScenarioSet().size(); contract.getReferentialSet().size(); return contract; } catch (NoResultException nre) { return null; } } }
ContractDAO extends AbstractJPADAO<Contract, Long> { @Override public Contract read(Long id) { try { Query query = entityManager.createQuery("SELECT 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.id = :id"); query.setParameter("id", id); Contract contract = (Contract) query.getSingleResult(); contract.getOptionElementSet().size(); contract.getFunctionalitySet().size(); contract.getScenarioSet().size(); contract.getReferentialSet().size(); return contract; } catch (NoResultException nre) { return null; } } ContractDAO(); }
ContractDAO extends AbstractJPADAO<Contract, Long> { @Override public Contract read(Long id) { try { Query query = entityManager.createQuery("SELECT 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.id = :id"); query.setParameter("id", id); Contract contract = (Contract) query.getSingleResult(); contract.getOptionElementSet().size(); contract.getFunctionalitySet().size(); contract.getScenarioSet().size(); contract.getReferentialSet().size(); return contract; } catch (NoResultException nre) { return null; } } ContractDAO(); @SuppressWarnings("unchecked") Collection<Contract> findAllContractsByUser(User user); @Override Contract read(Long id); }
ContractDAO extends AbstractJPADAO<Contract, Long> { @Override public Contract read(Long id) { try { Query query = entityManager.createQuery("SELECT 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.id = :id"); query.setParameter("id", id); Contract contract = (Contract) query.getSingleResult(); contract.getOptionElementSet().size(); contract.getFunctionalitySet().size(); contract.getScenarioSet().size(); contract.getReferentialSet().size(); return contract; } catch (NoResultException nre) { return null; } } ContractDAO(); @SuppressWarnings("unchecked") Collection<Contract> findAllContractsByUser(User user); @Override Contract read(Long id);  }