@Test public void testUpdate() { Contract contract = contractDAO.read((1L)); Float contractPrice = contract.getPrice(); contract.setPrice(contractPrice + 200); contractDAO.update(contract); assertEquals(contractPrice+200, contractDAO.read((1L)).getPrice()); }
@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);  }