List of usage examples for org.springframework.dao IncorrectResultSizeDataAccessException getMessage
@Override
@Nullable
public String getMessage()
From source file:com.sfs.whichdoctor.analysis.FinancialSummaryAnalysisDAOImpl.java
/** * Query for sub total.//from ww w . j a v a 2s . c o m * * @param sqlWHERE the sql where * @param sqlDate the sql date * @param sqlType the sql type * @param parameters the parameters * * @return the double */ private double queryForSubTotal(final String sqlWHERE, final String sqlDate, final String sqlType, final Collection<Object> parameters) { double subTotal = 0; dataLogger.debug("Query subtotal: " + sqlWHERE); StringBuffer searchSQL = new StringBuffer(); searchSQL.append(this.getSQL().getValue("financialSummary/total")); searchSQL.append(sqlWHERE); searchSQL.append(sqlDate); searchSQL.append(sqlType); searchSQL.append(this.sqlORDER); dataLogger.info("SQL query: " + searchSQL.toString()); try { subTotal = (Double) this.getJdbcTemplateReader().queryForObject(searchSQL.toString(), parameters.toArray(), new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return new Double(rs.getDouble(1)); } }); } catch (IncorrectResultSizeDataAccessException ie) { // No results found for this search dataLogger.debug("No results found for search: " + ie.getMessage()); } return subTotal; }
From source file:com.sfs.whichdoctor.dao.OnlineApplicationDAOImpl.java
/** * Used to get a OnlineApplicationBean for the the specified online application id. * Returns null if no online application found * * @param onlineApplicationId the online application id * * @return the online application bean/*from www.ja v a 2 s. co m*/ * * @throws WhichDoctorDaoException the which doctor dao exception */ public final OnlineApplicationBean load(final int onlineApplicationId) throws WhichDoctorDaoException { dataLogger.info("Online application id: " + onlineApplicationId + " requested"); OnlineApplicationBean onlineApplication = null; try { onlineApplication = (OnlineApplicationBean) this.getJdbcTemplateReader().queryForObject( this.getSQL().getValue("onlineapplication/loadId"), new Object[] { onlineApplicationId }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadOnlineApplicationBean(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } return onlineApplication; }
From source file:com.sfs.whichdoctor.dao.OnlineApplicationDAOImpl.java
/** * Used to get a OnlineApplicationBean for the the specified online application key. * Returns null if no online application found * * @param key the online application key * @param type the online application type * * @return the online application bean//w w w. j a va 2 s .c o m * * @throws WhichDoctorDaoException the which doctor dao exception */ public final OnlineApplicationBean load(final String key, final String type) throws WhichDoctorDaoException { dataLogger.info("Online application key: " + key + " requested"); OnlineApplicationBean onlineApplication = null; try { onlineApplication = (OnlineApplicationBean) this.getJdbcTemplateReader().queryForObject( this.getSQL().getValue("onlineapplication/loadKey"), new Object[] { key, type }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadOnlineApplicationBean(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } return onlineApplication; }
From source file:com.sfs.whichdoctor.dao.PaymentDAOImpl.java
/** * Used to get a PaymentBean for a specified PaymentId. * * @param paymentId the payment id//from w ww .j a v a 2s. co m * * @return the payment bean * * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final PaymentBean load(final int paymentId) throws WhichDoctorDaoException { dataLogger.info("PaymentId: " + paymentId + " requested"); final String loadPaymentId = getSQL().getValue("payment/load") + " WHERE payment.PaymentId = ?"; PaymentBean payment = null; try { payment = (PaymentBean) this.getJdbcTemplateReader().queryForObject(loadPaymentId, new Object[] { paymentId }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadPayment(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search:" + ie.getMessage()); } return payment; }
From source file:com.sfs.whichdoctor.dao.PaymentDAOImpl.java
/** * Used to get a PaymentBean for a specified GUID. * * @param guid the payment guid//from w ww . j a v a 2 s .c om * * @return the payment bean * * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final PaymentBean loadGUID(final int guid) throws WhichDoctorDaoException { dataLogger.info("Payment GUID: " + guid + " requested"); final String loadPaymentGUID = getSQL().getValue("payment/load") + " WHERE payment.Active = true AND payment.GUID = ?"; PaymentBean payment = null; try { payment = (PaymentBean) this.getJdbcTemplateReader().queryForObject(loadPaymentGUID, new Object[] { guid }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadPayment(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search:" + ie.getMessage()); } return payment; }
From source file:com.sfs.whichdoctor.dao.PaymentDAOImpl.java
/** * Used to get a Collection of PaymentBeans for a specified GUID number. * * @param guid the guid/*from www . j a v a 2 s .co m*/ * @param fullResults the full results * * @return the collection< payment bean> * * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final Collection<PaymentBean> load(final int guid, final boolean fullResults) throws WhichDoctorDaoException { dataLogger.info("Payments for GUID: " + guid + " requested"); final String loadPayment = getSQL().getValue("payment/load") + " WHERE payment.Active = true AND payment.ReferenceGUID = ?" + " AND (invoice.Active IS null OR invoice.Active = true)" + " ORDER BY payment.PersonId, payment.InvoiceId"; Collection<PaymentBean> payments = new ArrayList<PaymentBean>(); try { payments = this.getJdbcTemplateReader().query(loadPayment, new Object[] { guid }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadPayment(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search:" + ie.getMessage()); } return payments; }
From source file:com.sfs.whichdoctor.dao.WhichDoctorDAOImpl.java
/** * Load.//www .jav a2 s . c o m * * @param guid the guid * * @return the which doctor bean * * @throws WhichDoctorDaoException the which doctor dao exception */ public final WhichDoctorBean load(final int guid) throws WhichDoctorDaoException { dataLogger.info("Loading GUID: " + guid); WhichDoctorBean whichdoctorBean = null; try { whichdoctorBean = (WhichDoctorBean) this.getJdbcTemplateReader().queryForObject( getSQL().getValue("whichdoctor/load/guid"), new Object[] { guid }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadBean(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } return whichdoctorBean; }
From source file:com.sfs.whichdoctor.analysis.FinancialSummaryAnalysisDAOImpl.java
/** * Load transactions./* w w w. j a v a 2 s .c o m*/ * * @param searchResults the search results * @param loadDetails the load details * @param sqlWHERE the sql where * @param sqlLIMIT the sql limit * @param parameters the parameters * * @return the financial summary results bean * * @throws WhichDoctorAnalysisDaoException the which doctor analysis dao exception */ @SuppressWarnings("unchecked") private FinancialSummaryBean loadTransactions(final FinancialSummaryBean searchResults, final BuilderBean loadDetails, final String sqlWHERE, final String sqlLIMIT, final Collection<Object> parameters) throws WhichDoctorAnalysisDaoException { Collection<TransactionSummaryBean> results = new ArrayList<TransactionSummaryBean>(); final String searchSQL = getSQL().getValue("financialSummary/find") + sqlWHERE + this.sqlORDER + sqlLIMIT; dataLogger.info("SQL Query: " + searchSQL); Collection<TransactionSummaryBean> transactions = new ArrayList<TransactionSummaryBean>(); try { transactions = this.getJdbcTemplateReader().query(searchSQL, parameters.toArray(), new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadTransaction(rs, loadDetails); } }); } catch (IncorrectResultSizeDataAccessException ie) { // No results found for this search dataLogger.debug("No results found for search: " + ie.getMessage()); } double runningTotal = 0; boolean findRunningTotal = true; for (TransactionSummaryBean transaction : transactions) { if (findRunningTotal) { // Find running total by performing a balance search and set value. try { final double balance = getRunningTotal(sqlWHERE, parameters, transaction.getIssued(), transaction.getSummaryId()); final double total = searchResults.getOpeningBalance() + balance; searchResults.setBalanceBroughtForward(total); runningTotal = total; } catch (Exception e) { throw new WhichDoctorAnalysisDaoException("Could not get running balance: " + e.getMessage()); } findRunningTotal = false; } // Set running total by adding/subtracting net value from // runningTotal. if (!transaction.getCancelled()) { if (transaction.getDebit() != 0) { runningTotal += transaction.getDebit(); } if (transaction.getCredit() != 0) { runningTotal -= transaction.getCredit(); } } transaction.setTotal(runningTotal); results.add(transaction); } searchResults.setTransactions(results); return searchResults; }
From source file:com.sfs.whichdoctor.analysis.FinancialSummaryAnalysisDAOImpl.java
/** * Gets the running total.//from www. ja v a2s. c o m * * @param sqlWHERE the sql where * @param parameters the parameters * @param date the date * @param summaryId the summary id * * @return the running total */ @SuppressWarnings("unchecked") private double getRunningTotal(final String sqlWHERE, final Collection<Object> parameters, final Date date, final int summaryId) { double runningTotal = 0; runningTotal = getBalance(sqlWHERE, parameters, date, true); // Get a list of all the transactions on the // current day in order to find balance StringBuffer findBalanceSql = new StringBuffer(); findBalanceSql.append(this.getSQL().getValue("financialSummary/find")); findBalanceSql.append(sqlWHERE); findBalanceSql.append(" AND financial_summary.Issued = ?"); findBalanceSql.append(this.sqlORDER); String field = df.format(date); parameters.add(field); dataLogger.info("SQL Query: " + findBalanceSql.toString()); Collection<TransactionSummaryBean> transactions = new ArrayList<TransactionSummaryBean>(); try { transactions = this.getJdbcTemplateReader().query(findBalanceSql.toString(), parameters.toArray(), new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { TransactionSummaryBean transaction = new TransactionSummaryBean(); transaction.setSummaryId(rs.getInt("SummaryId")); transaction.setFinancialType(rs.getString("Class")); transaction.setCategory(rs.getString("Object")); transaction.setValue(rs.getDouble("Value")); transaction.setNetValue(rs.getDouble("NetValue")); transaction.setCancelled(rs.getBoolean("Cancelled")); return transaction; } }); } catch (IncorrectResultSizeDataAccessException ie) { // No results found for this search dataLogger.debug("No results found for search: " + ie.getMessage()); } for (TransactionSummaryBean transaction : transactions) { if (transaction.getSummaryId() != summaryId) { if (!transaction.getCancelled()) { if (StringUtils.equalsIgnoreCase(transaction.getCategory(), "Debit")) { runningTotal += transaction.getNetValue(); } if (StringUtils.equalsIgnoreCase(transaction.getCategory(), "Receipt")) { runningTotal -= transaction.getNetValue(); } if (StringUtils.equalsIgnoreCase(transaction.getCategory(), "Credit")) { if (StringUtils.equalsIgnoreCase(transaction.getFinancialType(), "Refund")) { runningTotal += transaction.getNetValue(); } else { runningTotal -= transaction.getNetValue(); } } } } else { return runningTotal; } } return runningTotal; }
From source file:com.sfs.whichdoctor.dao.OnlineToolDAOImpl.java
/** * Loads the requested online tool bean based on its id. * * @param referenceGUID the reference GUID * * @return the collection< online tool bean> * * @throws WhichDoctorDaoException the which doctor dao exception *//*from ww w. j a v a 2 s .c om*/ @SuppressWarnings("unchecked") public final OnlineToolBean loadId(final int onlineToolId) throws WhichDoctorDaoException { OnlineToolBean onlineTool = null; try { onlineTool = this.getJdbcTemplateReader().queryForObject(this.getSQL().getValue("onlineTool/loadId"), new Object[] { onlineToolId }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadOnlineTool(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } return onlineTool; }