List of usage examples for org.springframework.dao IncorrectResultSizeDataAccessException getMessage
@Override
@Nullable
public String getMessage()
From source file:om.edu.squ.squportal.portlet.dps.dao.db.DpsDbImpl.java
/** * //from w ww . ja va 2s .co m * method name : getStudentAcademicDetail * @param studentId * @param locale * @return * @throws NoDBRecordException * DpsDbImpl * return type : AcademicDetail * * purpose : * * Date : Jan 9, 2017 11:22:11 AM */ public AcademicDetail getStudentAcademicDetail(String studentId, String studentNo, Locale locale) throws NoDBRecordException, NotCorrectDBRecordException { String SQL_ACADEMIC_DETAIL_STUDENT = queryProps.getProperty(Constants.SQL_ACADEMIC_DETAIL_STUDENT); RowMapper<AcademicDetail> mapper = new RowMapper<AcademicDetail>() { public AcademicDetail mapRow(ResultSet rs, int rowNum) throws SQLException { AcademicDetail academicDetail = new AcademicDetail(); academicDetail.setId(rs.getString(Constants.CONST_COLMN_STUDENT_ID)); academicDetail.setStudentNo(rs.getString(Constants.CONST_COLMN_STUDENT_NO)); academicDetail.setStdStatCode(rs.getString(Constants.CONST_COLMN_STDSTATCD)); academicDetail.setCollege(rs.getString(Constants.CONST_COLMN_COLLEGE_NAME)); academicDetail.setMajor(rs.getString(Constants.CONST_COLMN_MAJOR_NAME)); academicDetail.setAdvisorId(rs.getString(Constants.CONST_COLMN_ADVISOR_ID)); academicDetail.setSupervisorId(rs.getString(Constants.CONST_COLMN_SUPERVISOR_ID)); academicDetail.setDegree(rs.getString(Constants.CONST_COLMN_DEGREE_NAME)); academicDetail.setStatus(rs.getString(Constants.CONST_COLMN_STATUS_NAME)); return academicDetail; } }; Map<String, String> namedParameterMap = new HashMap<String, String>(); namedParameterMap.put("paramLocale", locale.getLanguage()); namedParameterMap.put("paramStudentId", studentId); namedParameterMap.put("paramStudentNo", studentNo); try { return nPJdbcTemplDps.queryForObject(SQL_ACADEMIC_DETAIL_STUDENT, namedParameterMap, mapper); } catch (EmptyResultDataAccessException ex) { throw new NoDBRecordException(ex.getMessage()); } catch (IncorrectResultSizeDataAccessException exNotCorrectResultSize) { logger.error("DB Error : Error Thrown and to be catched in Service layer"); throw new NotCorrectDBRecordException(exNotCorrectResultSize.getMessage()); } }
From source file:com.sfs.whichdoctor.dao.ItemDAOImpl.java
/** * Used to get a TreeMap of ItemBean details for a specified GUID number. * * @param guid the guid// w w w .j a va 2 s . c o m * @param fullResults the full results * @param itemTypeVal the item type value * @param groupClassVal the group class value * @param object2GUID the object2 guid * @param startDate the start date * @param endDate the end date * * @return the tree map< string, item bean> * * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final TreeMap<String, ItemBean> load(final int guid, final boolean fullResults, final String itemTypeVal, final String groupClassVal, final int object2GUID, final String startDate, final String endDate) throws WhichDoctorDaoException { TreeMap<String, ItemBean> items = new TreeMap<String, ItemBean>(); String itemType = "Group"; String groupClass = "Members"; if (itemTypeVal != null) { itemType = itemTypeVal; } if (groupClass != null) { groupClass = groupClassVal; } if (StringUtils.equalsIgnoreCase(itemType, "Employer") || StringUtils.equalsIgnoreCase(itemType, "Employee")) { itemType = "Employment"; } java.util.Date dtStartDate = null; java.util.Date dtEndDate = null; DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.UK); try { dtStartDate = df.parse(startDate); } catch (Exception e) { dataLogger.debug("Error parsing start date: " + e.getMessage()); } try { dtEndDate = df.parse(endDate); } catch (Exception e) { dataLogger.debug("Error parsing end date: " + e.getMessage()); } if (dtStartDate != null && dtEndDate != null && dtStartDate.compareTo(dtEndDate) > 0) { /* Start date is greater than end date, switch around */ java.util.Date tempStartDate = dtStartDate; dtStartDate = dtEndDate; dtEndDate = tempStartDate; } StringBuffer loadItems = new StringBuffer(); ArrayList<Object> parameters = new ArrayList<Object>(); parameters.add(guid); parameters.add(itemType); loadItems.append(getLoadSQL(groupClass)); if (StringUtils.equalsIgnoreCase(groupClass, "Employers")) { loadItems.append(" AND items.Object2GUID = ? AND itemtype.Class = ?"); } else { loadItems.append(" AND items.Object1GUID = ? AND itemtype.Class = ?"); } if (object2GUID > 0) { loadItems.append(" AND items.Object2GUID = ?"); parameters.add(object2GUID); } dataLogger.info("Items for GUID: " + guid + " requested"); Collection<ItemBean> itemCollection = new ArrayList<ItemBean>(); try { itemCollection = this.getJdbcTemplateReader().query(loadItems.toString(), parameters.toArray(), new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadItem(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } for (ItemBean item : itemCollection) { if (item.display(dtStartDate, dtEndDate)) { items.put(item.getOrderIndex(), item); } } return items; }
From source file:com.sfs.whichdoctor.dao.ReimbursementDAOImpl.java
/** * Get a ReimbursementBean for a specified name and supplied load details. * * @param strReimbursement the str reimbursement * @param loadDetails the load details/*from w w w .ja v a2s.co m*/ * * @return the reimbursement bean * * @throws WhichDoctorDaoException the which doctor dao exception */ public final ReimbursementBean load(final String strReimbursement, final BuilderBean loadDetails) throws WhichDoctorDaoException { dataLogger.info("Reimbursement Name: " + strReimbursement + " requested"); int reimbursementGUID = 0; final String loadSQL = getSQL().getValue("reimbursement/loadName"); try { reimbursementGUID = this.getJdbcTemplateReader().queryForInt(loadSQL, new Object[] { strReimbursement }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for search: " + ie.getMessage()); } if (reimbursementGUID > 0) { return loadGUID(reimbursementGUID, loadDetails); } else { throw new WhichDoctorDaoException( "Sorry no reimbursement matching " + "those details could be identified"); } }
From source file:com.sfs.whichdoctor.dao.ReimbursementDAOImpl.java
/** * Get a ReimbursementBean for a specified guid and supplied load details. * * @param guid the guid/*from ww w . j a v a 2 s.co m*/ * @param loadDetails the load details * * @return the reimbursement bean * * @throws WhichDoctorDaoException the which doctor dao exception */ public final ReimbursementBean loadGUID(final int guid, final BuilderBean loadDetails) throws WhichDoctorDaoException { dataLogger.info("Reimbursement GUID: " + guid + " requested"); ReimbursementBean reimbursement = null; final String loadSQL = getSQL().getValue("reimbursement/load") + " AND reimbursement.Active = true AND reimbursement.GUID = ?" + " GROUP BY reimbursement.ReimbursementId"; try { reimbursement = (ReimbursementBean) this.getJdbcTemplateReader().queryForObject(loadSQL, new Object[] { guid }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadReimbursement(rs, loadDetails); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for search: " + ie.getMessage()); } return reimbursement; }
From source file:com.sfs.whichdoctor.dao.ReimbursementDAOImpl.java
/** * Get a ReimbursementBean for a specified reimbursementId with the supplied * load details. A boolean parameter identifies whether to use the default * reader connection or optional writer connection datasource. * * @param reimbursementId the reimbursement id * @param loadDetails the load details//from w w w.j a va 2s . com * @param useWriterConn the use writer conn * * @return the reimbursement bean * * @throws WhichDoctorDaoException the which doctor dao exception */ private ReimbursementBean load(final int reimbursementId, final BuilderBean loadDetails, final boolean useWriterConn) throws WhichDoctorDaoException { dataLogger.info("Reimbursement Id: " + reimbursementId + " requested"); ReimbursementBean reimbursement = null; final String loadSQL = this.getSQL().getValue("reimbursement/load") + " AND reimbursement.ReimbursementId = ? " + "GROUP BY reimbursement.ReimbursementId"; JdbcTemplate jdbcTemplate = this.getJdbcTemplateReader(); if (useWriterConn) { jdbcTemplate = this.getJdbcTemplateWriter(); } try { reimbursement = (ReimbursementBean) jdbcTemplate.queryForObject(loadSQL, new Object[] { reimbursementId }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadReimbursement(rs, loadDetails); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for search: " + ie.getMessage()); } return reimbursement; }
From source file:com.sfs.whichdoctor.analysis.RevenueAnalysisDAOImpl.java
/** * Batch analysis.//from w w w .ja v a 2 s . co m * * @param search the search * * @return the revenue analysis bean * * @throws WhichDoctorAnalysisDaoException the which doctor analysis dao * exception */ @SuppressWarnings("unchecked") public final RevenueAnalysisBean batchAnalysis(final RevenueAnalysisBean search) throws WhichDoctorAnalysisDaoException { /* Zero out values in revenue analysis bean */ search.setValue(0); search.setNetValue(0); /* Set ordering system of returned results */ String sqlORDER = " ORDER BY receipt.BatchReference, receipt.ReceiptNo"; StringBuffer sqlWHERE = new StringBuffer(); Collection<Object> parameters = new ArrayList<Object>(); if (search.getSQLWhereStatement() != null) { if (search.getSQLWhereStatement().compareTo("") != 0) { sqlWHERE.append(" AND "); sqlWHERE.append(search.getSQLWhereStatement()); } } if (search.getSearchParameters() != null) { parameters = search.getSearchParameters(); } /* BUILD SQL Statement */ final StringBuffer searchSQL = new StringBuffer(); searchSQL.append(this.getSQL().getValue("revenue")); searchSQL.append(sqlWHERE.toString()); searchSQL.append(" GROUP BY payment.PaymentId, receipt.BatchReference "); searchSQL.append(sqlORDER); dataLogger.info("SQL Query: " + searchSQL.toString()); Collection<RevenueBean> results = new ArrayList<RevenueBean>(); try { results = this.getJdbcTemplateReader().query(searchSQL.toString(), parameters.toArray(), new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadBatchRevenue(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { // No results found for this search dataLogger.debug("No results found for this search: " + ie.getMessage()); } final TreeMap<Object, ArrayList<RevenueBean>> batchMap = new TreeMap<Object, ArrayList<RevenueBean>>(); for (RevenueBean revenue : results) { ArrayList<RevenueBean> revenueList = new ArrayList<RevenueBean>(); if (batchMap.containsKey(revenue.getBatchReference())) { revenueList = batchMap.get(revenue.getBatchReference()); } revenueList.add(revenue); batchMap.put(revenue.getBatchReference(), revenueList); } final RevenueAnalysisBean summary = consolidateSummary(batchMap); search.setValue(summary.getValue()); search.setNetValue(summary.getNetValue()); search.setGSTValues(summary.getGSTValues()); search.setRevenue(summary.getRevenue()); return search; }
From source file:com.sfs.whichdoctor.analysis.RevenueAnalysisDAOImpl.java
/** * Stream analysis.// w ww . j a v a 2 s.co m * * @param search the search * * @return the revenue analysis bean * * @throws WhichDoctorAnalysisDaoException the which doctor analysis dao * exception */ @SuppressWarnings("unchecked") public final RevenueAnalysisBean streamAnalysis(final RevenueAnalysisBean search) throws WhichDoctorAnalysisDaoException { /* Zero out values in revenueanalysis bean */ search.setValue(0); search.setNetValue(0); /* Set ordering system of returned results */ String sqlORDER = " ORDER BY RevenueType, receipt.ReceiptNo"; final StringBuffer sqlWHERE = new StringBuffer(); Collection<Object> parameters = new ArrayList<Object>(); if (search.getSQLWhereStatement() != null) { if (search.getSQLWhereStatement().compareTo("") != 0) { sqlWHERE.append(" AND "); sqlWHERE.append(search.getSQLWhereStatement()); } } if (search.getSearchParameters() != null) { parameters = search.getSearchParameters(); } // BUILD SQL Statement final StringBuffer searchSQL = new StringBuffer(); searchSQL.append(this.getSQL().getValue("revenue")); searchSQL.append(sqlWHERE.toString()); searchSQL.append(" GROUP BY payment.PaymentId, RevenueType "); searchSQL.append(sqlORDER); dataLogger.info("SQL Query: " + searchSQL.toString()); Collection<RevenueBean> results = new ArrayList<RevenueBean>(); try { results = this.getJdbcTemplateReader().query(searchSQL.toString(), parameters.toArray(), new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadStreamRevenue(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { // No results found for this search dataLogger.debug("No results found for search: " + ie.getMessage()); } TreeMap<Object, ArrayList<RevenueBean>> revenueTypeMap = new TreeMap<Object, ArrayList<RevenueBean>>(); for (RevenueBean revenue : results) { if (dataLogger.isDebugEnabled()) { dataLogger.debug("Net value: " + revenue.getNetValue()); dataLogger.debug("Value: " + revenue.getValue()); } ArrayList<RevenueBean> revenueList = new ArrayList<RevenueBean>(); if (revenueTypeMap.containsKey(revenue.getRevenueType())) { revenueList = revenueTypeMap.get(revenue.getRevenueType()); } revenueList.add(revenue); revenueTypeMap.put(revenue.getRevenueType(), revenueList); } final RevenueAnalysisBean summary = consolidateSummary(revenueTypeMap); search.setValue(summary.getValue()); search.setNetValue(summary.getNetValue()); search.setGSTValues(summary.getGSTValues()); search.setRevenue(summary.getRevenue()); return search; }
From source file:com.sfs.whichdoctor.dao.GroupDAOImpl.java
/** * Load a GroupBean for the specified name and provided load details. * * @param name the name//from w w w. j av a2 s . c o m * @param loadDetails the load details * * @return the group bean * * @throws WhichDoctorDaoException the which doctor dao exception */ public final GroupBean load(final String name, final BuilderBean loadDetails) throws WhichDoctorDaoException { final String loadSQL = getSQL().getValue("group/loadName"); int groupGUID = 0; try { groupGUID = this.getJdbcTemplateReader().queryForInt(loadSQL, new Object[] { name }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for the search: " + ie.getMessage()); } if (groupGUID > 0) { return loadGUID(groupGUID, loadDetails); } else { throw new WhichDoctorDaoException("No group matching that name could be identified"); } }
From source file:com.sfs.whichdoctor.dao.GroupDAOImpl.java
/** * Load a GroupBean for the specified GUID and provided load details. * * @param guid the guid/*from w ww. j a v a 2s.c om*/ * @param loadDetails the load details * * @return the group bean * * @throws WhichDoctorDaoException the which doctor dao exception */ public final GroupBean loadGUID(final int guid, final BuilderBean loadDetails) throws WhichDoctorDaoException { GroupBean group = null; final String loadSQL = getSQL().getValue("group/load") + " AND groups.Active = true AND groups.GUID = ?" + " GROUP BY groups.GroupId"; try { group = (GroupBean) this.getJdbcTemplateReader().queryForObject(loadSQL, new Object[] { guid }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadGroup(rs, loadDetails); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for the search: " + ie.getMessage()); } return group; }
From source file:com.sfs.whichdoctor.dao.GroupDAOImpl.java
/** * Load a GroupBean for the specified groupId and provided load details. * * @param groupId the group id// www. ja va2 s .com * @param loadDetails the load details * @param useWriterConn use the writer connection * * @return the group bean * * @throws WhichDoctorDaoException the which doctor dao exception */ private GroupBean load(final int groupId, final BuilderBean loadDetails, final boolean useWriterConn) throws WhichDoctorDaoException { GroupBean group = null; JdbcTemplate jdbcTemplate = this.getJdbcTemplateReader(); if (useWriterConn) { jdbcTemplate = this.getJdbcTemplateWriter(); } final String loadSQL = getSQL().getValue("group/load") + " AND groups.GroupId = ? GROUP BY groups.GroupId"; try { group = (GroupBean) jdbcTemplate.queryForObject(loadSQL, new Object[] { groupId }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadGroup(rs, loadDetails); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for the search: " + ie.getMessage()); } return group; }