@Test public void testUpdate() { MarriageRegnRequest marriageRegnRequest = new MarriageRegnRequest(); RequestInfo requestInfo = new RequestInfo(); List<MarriageRegn> marriageRegns = getMarriageRegnFromDB(); marriageRegnRequest.setMarriageRegn(marriageRegns.get(0)); marriageRegnRequest.setRequestInfo(requestInfo); when(jdbcTemplate.update(any(String.class), any(Object[].class))).thenReturn(1); }
public void update(MarriageRegn marriageRegn) { jdbcTemplate.update(UPDATE_MARRIAGE_REGN_QUERY, new PreparedStatementSetter(){ @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setLong(1, marriageRegn.getRegnUnit().getId()); ps.setLong(2, marriageRegn.getMarriageDate()); ps.setString(3, marriageRegn.getVenue().toString()); ps.setString(4, marriageRegn.getStreet()); ps.setString(5, marriageRegn.getPlaceOfMarriage()); ps.setString(6, marriageRegn.getLocality()); ps.setString(7, marriageRegn.getCity()); ps.setString(8, marriageRegn.getMarriagePhoto()); ps.setLong(9, marriageRegn.getBridegroom().getId()); ps.setLong(10, marriageRegn.getBride().getId()); ps.setString(11, marriageRegn.getFee().getId()); ps.setString(12, marriageRegn.getDemands().get(0).getId()); ps.setString(13, marriageRegn.getPriest().getName()); ps.setLong(14, marriageRegn.getPriest().getReligion()); ps.setString(15, marriageRegn.getPriest().getAddress()); ps.setString(16, marriageRegn.getPriest().getAadhaar()); ps.setString(17, marriageRegn.getPriest().getMobileNo()); ps.setString(18, marriageRegn.getPriest().getEmail()); ps.setString(19, marriageRegn.getSerialNo()); ps.setString(20, marriageRegn.getVolumeNo()); ps.setString(21, marriageRegn.getRegnNumber()); ps.setLong(22, marriageRegn.getRegnDate()); ps.setString(23, marriageRegn.getStatus().toString()); ps.setString(24, marriageRegn.getSource().toString()); ps.setString(25, marriageRegn.getStateId()); ps.setBoolean(26, marriageRegn.getIsActive()); ps.setLong(27, marriageRegn.getApprovalDetails().getDepartment()); ps.setLong(28, marriageRegn.getApprovalDetails().getDesignation()); ps.setLong(29, marriageRegn.getApprovalDetails().getAssignee()); ps.setString(30, marriageRegn.getApprovalDetails().getAction()); ps.setString(31, marriageRegn.getApprovalDetails().getStatus()); ps.setString(32, marriageRegn.getApprovalDetails().getComments()); ps.setString(33, marriageRegn.getAuditDetails().getLastModifiedBy()); ps.setLong(34, marriageRegn.getAuditDetails().getLastModifiedTime()); ps.setString(35, marriageRegn.getTenantId()); ps.setString(36, marriageRegn.getApplicationNumber()); } }); if (marriageRegn.getWitnesses() != null) marriageRegn.getWitnesses().forEach(witness -> { witnessRepository.update(marriageRegn.getApplicationNumber(), marriageRegn.getTenantId(), witness); }); }
MarriageRegnRepository { public void update(MarriageRegn marriageRegn) { jdbcTemplate.update(UPDATE_MARRIAGE_REGN_QUERY, new PreparedStatementSetter(){ @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setLong(1, marriageRegn.getRegnUnit().getId()); ps.setLong(2, marriageRegn.getMarriageDate()); ps.setString(3, marriageRegn.getVenue().toString()); ps.setString(4, marriageRegn.getStreet()); ps.setString(5, marriageRegn.getPlaceOfMarriage()); ps.setString(6, marriageRegn.getLocality()); ps.setString(7, marriageRegn.getCity()); ps.setString(8, marriageRegn.getMarriagePhoto()); ps.setLong(9, marriageRegn.getBridegroom().getId()); ps.setLong(10, marriageRegn.getBride().getId()); ps.setString(11, marriageRegn.getFee().getId()); ps.setString(12, marriageRegn.getDemands().get(0).getId()); ps.setString(13, marriageRegn.getPriest().getName()); ps.setLong(14, marriageRegn.getPriest().getReligion()); ps.setString(15, marriageRegn.getPriest().getAddress()); ps.setString(16, marriageRegn.getPriest().getAadhaar()); ps.setString(17, marriageRegn.getPriest().getMobileNo()); ps.setString(18, marriageRegn.getPriest().getEmail()); ps.setString(19, marriageRegn.getSerialNo()); ps.setString(20, marriageRegn.getVolumeNo()); ps.setString(21, marriageRegn.getRegnNumber()); ps.setLong(22, marriageRegn.getRegnDate()); ps.setString(23, marriageRegn.getStatus().toString()); ps.setString(24, marriageRegn.getSource().toString()); ps.setString(25, marriageRegn.getStateId()); ps.setBoolean(26, marriageRegn.getIsActive()); ps.setLong(27, marriageRegn.getApprovalDetails().getDepartment()); ps.setLong(28, marriageRegn.getApprovalDetails().getDesignation()); ps.setLong(29, marriageRegn.getApprovalDetails().getAssignee()); ps.setString(30, marriageRegn.getApprovalDetails().getAction()); ps.setString(31, marriageRegn.getApprovalDetails().getStatus()); ps.setString(32, marriageRegn.getApprovalDetails().getComments()); ps.setString(33, marriageRegn.getAuditDetails().getLastModifiedBy()); ps.setLong(34, marriageRegn.getAuditDetails().getLastModifiedTime()); ps.setString(35, marriageRegn.getTenantId()); ps.setString(36, marriageRegn.getApplicationNumber()); } }); if (marriageRegn.getWitnesses() != null) marriageRegn.getWitnesses().forEach(witness -> { witnessRepository.update(marriageRegn.getApplicationNumber(), marriageRegn.getTenantId(), witness); }); } }
MarriageRegnRepository { public void update(MarriageRegn marriageRegn) { jdbcTemplate.update(UPDATE_MARRIAGE_REGN_QUERY, new PreparedStatementSetter(){ @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setLong(1, marriageRegn.getRegnUnit().getId()); ps.setLong(2, marriageRegn.getMarriageDate()); ps.setString(3, marriageRegn.getVenue().toString()); ps.setString(4, marriageRegn.getStreet()); ps.setString(5, marriageRegn.getPlaceOfMarriage()); ps.setString(6, marriageRegn.getLocality()); ps.setString(7, marriageRegn.getCity()); ps.setString(8, marriageRegn.getMarriagePhoto()); ps.setLong(9, marriageRegn.getBridegroom().getId()); ps.setLong(10, marriageRegn.getBride().getId()); ps.setString(11, marriageRegn.getFee().getId()); ps.setString(12, marriageRegn.getDemands().get(0).getId()); ps.setString(13, marriageRegn.getPriest().getName()); ps.setLong(14, marriageRegn.getPriest().getReligion()); ps.setString(15, marriageRegn.getPriest().getAddress()); ps.setString(16, marriageRegn.getPriest().getAadhaar()); ps.setString(17, marriageRegn.getPriest().getMobileNo()); ps.setString(18, marriageRegn.getPriest().getEmail()); ps.setString(19, marriageRegn.getSerialNo()); ps.setString(20, marriageRegn.getVolumeNo()); ps.setString(21, marriageRegn.getRegnNumber()); ps.setLong(22, marriageRegn.getRegnDate()); ps.setString(23, marriageRegn.getStatus().toString()); ps.setString(24, marriageRegn.getSource().toString()); ps.setString(25, marriageRegn.getStateId()); ps.setBoolean(26, marriageRegn.getIsActive()); ps.setLong(27, marriageRegn.getApprovalDetails().getDepartment()); ps.setLong(28, marriageRegn.getApprovalDetails().getDesignation()); ps.setLong(29, marriageRegn.getApprovalDetails().getAssignee()); ps.setString(30, marriageRegn.getApprovalDetails().getAction()); ps.setString(31, marriageRegn.getApprovalDetails().getStatus()); ps.setString(32, marriageRegn.getApprovalDetails().getComments()); ps.setString(33, marriageRegn.getAuditDetails().getLastModifiedBy()); ps.setLong(34, marriageRegn.getAuditDetails().getLastModifiedTime()); ps.setString(35, marriageRegn.getTenantId()); ps.setString(36, marriageRegn.getApplicationNumber()); } }); if (marriageRegn.getWitnesses() != null) marriageRegn.getWitnesses().forEach(witness -> { witnessRepository.update(marriageRegn.getApplicationNumber(), marriageRegn.getTenantId(), witness); }); }  }
MarriageRegnRepository { public void update(MarriageRegn marriageRegn) { jdbcTemplate.update(UPDATE_MARRIAGE_REGN_QUERY, new PreparedStatementSetter(){ @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setLong(1, marriageRegn.getRegnUnit().getId()); ps.setLong(2, marriageRegn.getMarriageDate()); ps.setString(3, marriageRegn.getVenue().toString()); ps.setString(4, marriageRegn.getStreet()); ps.setString(5, marriageRegn.getPlaceOfMarriage()); ps.setString(6, marriageRegn.getLocality()); ps.setString(7, marriageRegn.getCity()); ps.setString(8, marriageRegn.getMarriagePhoto()); ps.setLong(9, marriageRegn.getBridegroom().getId()); ps.setLong(10, marriageRegn.getBride().getId()); ps.setString(11, marriageRegn.getFee().getId()); ps.setString(12, marriageRegn.getDemands().get(0).getId()); ps.setString(13, marriageRegn.getPriest().getName()); ps.setLong(14, marriageRegn.getPriest().getReligion()); ps.setString(15, marriageRegn.getPriest().getAddress()); ps.setString(16, marriageRegn.getPriest().getAadhaar()); ps.setString(17, marriageRegn.getPriest().getMobileNo()); ps.setString(18, marriageRegn.getPriest().getEmail()); ps.setString(19, marriageRegn.getSerialNo()); ps.setString(20, marriageRegn.getVolumeNo()); ps.setString(21, marriageRegn.getRegnNumber()); ps.setLong(22, marriageRegn.getRegnDate()); ps.setString(23, marriageRegn.getStatus().toString()); ps.setString(24, marriageRegn.getSource().toString()); ps.setString(25, marriageRegn.getStateId()); ps.setBoolean(26, marriageRegn.getIsActive()); ps.setLong(27, marriageRegn.getApprovalDetails().getDepartment()); ps.setLong(28, marriageRegn.getApprovalDetails().getDesignation()); ps.setLong(29, marriageRegn.getApprovalDetails().getAssignee()); ps.setString(30, marriageRegn.getApprovalDetails().getAction()); ps.setString(31, marriageRegn.getApprovalDetails().getStatus()); ps.setString(32, marriageRegn.getApprovalDetails().getComments()); ps.setString(33, marriageRegn.getAuditDetails().getLastModifiedBy()); ps.setLong(34, marriageRegn.getAuditDetails().getLastModifiedTime()); ps.setString(35, marriageRegn.getTenantId()); ps.setString(36, marriageRegn.getApplicationNumber()); } }); if (marriageRegn.getWitnesses() != null) marriageRegn.getWitnesses().forEach(witness -> { witnessRepository.update(marriageRegn.getApplicationNumber(), marriageRegn.getTenantId(), witness); }); }  @SuppressWarnings("unchecked") List<MarriageRegn> findForCriteria(MarriageRegnCriteria marriageRegnCriteria); void save(MarriageRegn marriageRegn); String generateApplicationNumber(); void update(MarriageRegn marriageRegn); void saveJson(String applicationNumber, String marriageRegnJson, String tenantId); }
MarriageRegnRepository { public void update(MarriageRegn marriageRegn) { jdbcTemplate.update(UPDATE_MARRIAGE_REGN_QUERY, new PreparedStatementSetter(){ @Override public void setValues(PreparedStatement ps) throws SQLException { ps.setLong(1, marriageRegn.getRegnUnit().getId()); ps.setLong(2, marriageRegn.getMarriageDate()); ps.setString(3, marriageRegn.getVenue().toString()); ps.setString(4, marriageRegn.getStreet()); ps.setString(5, marriageRegn.getPlaceOfMarriage()); ps.setString(6, marriageRegn.getLocality()); ps.setString(7, marriageRegn.getCity()); ps.setString(8, marriageRegn.getMarriagePhoto()); ps.setLong(9, marriageRegn.getBridegroom().getId()); ps.setLong(10, marriageRegn.getBride().getId()); ps.setString(11, marriageRegn.getFee().getId()); ps.setString(12, marriageRegn.getDemands().get(0).getId()); ps.setString(13, marriageRegn.getPriest().getName()); ps.setLong(14, marriageRegn.getPriest().getReligion()); ps.setString(15, marriageRegn.getPriest().getAddress()); ps.setString(16, marriageRegn.getPriest().getAadhaar()); ps.setString(17, marriageRegn.getPriest().getMobileNo()); ps.setString(18, marriageRegn.getPriest().getEmail()); ps.setString(19, marriageRegn.getSerialNo()); ps.setString(20, marriageRegn.getVolumeNo()); ps.setString(21, marriageRegn.getRegnNumber()); ps.setLong(22, marriageRegn.getRegnDate()); ps.setString(23, marriageRegn.getStatus().toString()); ps.setString(24, marriageRegn.getSource().toString()); ps.setString(25, marriageRegn.getStateId()); ps.setBoolean(26, marriageRegn.getIsActive()); ps.setLong(27, marriageRegn.getApprovalDetails().getDepartment()); ps.setLong(28, marriageRegn.getApprovalDetails().getDesignation()); ps.setLong(29, marriageRegn.getApprovalDetails().getAssignee()); ps.setString(30, marriageRegn.getApprovalDetails().getAction()); ps.setString(31, marriageRegn.getApprovalDetails().getStatus()); ps.setString(32, marriageRegn.getApprovalDetails().getComments()); ps.setString(33, marriageRegn.getAuditDetails().getLastModifiedBy()); ps.setLong(34, marriageRegn.getAuditDetails().getLastModifiedTime()); ps.setString(35, marriageRegn.getTenantId()); ps.setString(36, marriageRegn.getApplicationNumber()); } }); if (marriageRegn.getWitnesses() != null) marriageRegn.getWitnesses().forEach(witness -> { witnessRepository.update(marriageRegn.getApplicationNumber(), marriageRegn.getTenantId(), witness); }); }  @SuppressWarnings("unchecked") List<MarriageRegn> findForCriteria(MarriageRegnCriteria marriageRegnCriteria); void save(MarriageRegn marriageRegn); String generateApplicationNumber(); void update(MarriageRegn marriageRegn); void saveJson(String applicationNumber, String marriageRegnJson, String tenantId); static final String INSERT_JSON_QUERY; static final String INSERT_MARRIAGE_REGN_QUERY; static final String UPDATE_MARRIAGE_REGN_QUERY; }