Example usage for org.springframework.dao IncorrectResultSizeDataAccessException getMessage

List of usage examples for org.springframework.dao IncorrectResultSizeDataAccessException getMessage

Introduction

In this page you can find the example usage for org.springframework.dao IncorrectResultSizeDataAccessException getMessage.

Prototype

@Override
@Nullable
public String getMessage() 

Source Link

Document

Return the detail message, including the message from the nested exception if there is one.

Usage

From source file:com.sfs.whichdoctor.dao.AccreditationDAOImpl.java

/**
 * Load a collection of AccreditationBeans.
 *
 * @param guid the guid//from  w  w w.  j a  v  a 2 s .  c o m
 * @param fullResults the full results
 *
 * @return the collection< accreditation bean>
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
@SuppressWarnings("unchecked")
public final Collection<AccreditationBean> load(final int guid, final boolean fullResults)
        throws WhichDoctorDaoException {

    dataLogger.info("Accreditations for GUID: " + guid + " requested");

    final String loadAccreditation = getSQL().getValue("accreditation/load")
            + " WHERE accreditation.Active = true" + " AND accreditation.ReferenceGUID = ?"
            + " ORDER BY accreditation.Core DESC," + " specialtytype.Class ASC, specialtytype.Name ASC";

    Collection<AccreditationBean> accreditations = new ArrayList<AccreditationBean>();

    try {
        accreditations = this.getJdbcTemplateReader().query(loadAccreditation, new Object[] { guid },
                new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadAccreditation(rs);
                    }
                });

    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for search: " + ie.getMessage());
    }
    return accreditations;
}

From source file:com.sfs.whichdoctor.dao.SupervisorDAOImpl.java

/**
 * Used to get a SupervisorBean for a specified supervisor Id.
 *
 * @param supervisorId the supervisor id
 *
 * @return the supervisor bean//from  ww  w. jav  a2 s  .c om
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final SupervisorBean load(final int supervisorId) throws WhichDoctorDaoException {

    dataLogger.info("SupervisorId: " + supervisorId + " requested");

    final String loadSupervisorId = getSQL().getValue("supervisor/load")
            + " WHERE supervisors.SupervisorId = ?";

    SupervisorBean supervisor = null;

    final BuilderBean loadDetails = new BuilderBean();
    loadDetails.setParameter("SUPERVISOR_PERSONOBJ", true);

    try {
        supervisor = (SupervisorBean) this.getJdbcTemplateReader().queryForObject(loadSupervisorId,
                new Object[] { supervisorId }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadSupervisor(rs, loadDetails);
                    }
                });

    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for search: " + ie.getMessage());
    }
    return supervisor;
}

From source file:com.sfs.whichdoctor.dao.SupervisorDAOImpl.java

/**
 * Used to get a SupervisorBean for a specified supervisor GUID.
 *
 * @param guid the guid// w ww. ja v a 2 s  . c  o  m
 *
 * @return the supervisor bean
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final SupervisorBean loadGUID(final int guid) throws WhichDoctorDaoException {

    dataLogger.info("Supervisor GUID: " + guid + " requested");

    final String loadSupervisorId = getSQL().getValue("supervisor/load")
            + " WHERE supervisors.Active = true AND supervisors.GUID = ?";

    SupervisorBean supervisor = null;

    final BuilderBean loadDetails = new BuilderBean();
    loadDetails.setParameter("SUPERVISOR_PERSONOBJ", true);

    try {
        supervisor = (SupervisorBean) this.getJdbcTemplateReader().queryForObject(loadSupervisorId,
                new Object[] { guid }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadSupervisor(rs, loadDetails);
                    }
                });

    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for search: " + ie.getMessage());
    }
    return supervisor;
}

From source file:com.sfs.whichdoctor.dao.SupervisorDAOImpl.java

/**
 * Used to get a Collection of SupervisorBeans for a specified GUID.
 *
 * @param guid the guid/*from w ww .  j ava  2s. co m*/
 * @param loadDetails the load details
 *
 * @return the collection< supervisor bean>
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
@SuppressWarnings("unchecked")
public final Collection<SupervisorBean> load(final int guid, final BuilderBean loadDetails)
        throws WhichDoctorDaoException {

    dataLogger.info("Supervisors for GUID: " + guid + " requested");

    final String loadSupervisors = getSQL().getValue("supervisor/load")
            + " WHERE supervisors.Active = true AND supervisors.ReferenceGUID = ?"
            + " ORDER BY supervisors.OrderId ASC, relationshiptype.Class ASC,"
            + " relationshiptype.Name ASC, people.LastName ASC";

    Collection<SupervisorBean> supervisors = new ArrayList<SupervisorBean>();

    try {
        supervisors = this.getJdbcTemplateReader().query(loadSupervisors, new Object[] { guid },
                new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadSupervisor(rs, loadDetails);
                    }
                });

    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for search: " + ie.getMessage());
    }
    return supervisors;
}

From source file:com.sfs.whichdoctor.dao.SupervisorDAOImpl.java

/**
 * Used to get a SupervisorBean for a related rotation or organisation based
 * on the supplied hierarchy, relationship class and division parameters.
 *
 * @param referenceGUID - the GUID of the rotation or organisation
 * @param hierarchy - the hierarchy value (must be greater than zero)
 * @param relationshipClass - the relationship class
 * @param division - the training division
 *
 * @return - The identified supervisor. A null object is returned if no
 * supervisor is found, or if the hierarchy = 0 and/or the division
 * is null/empty string./*from   w w  w.j a  v  a 2 s  .c o  m*/
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final SupervisorBean load(final int referenceGUID, final int hierarchy, final String relationshipClass,
        final String division) throws WhichDoctorDaoException {

    dataLogger.info("Supervisor for reference GUID: " + referenceGUID + ", hierarchy: " + hierarchy
            + ", relationship class: " + relationshipClass + ", division: " + division);

    SupervisorBean supervisor = null;

    if (referenceGUID > 0 && hierarchy > 0 && StringUtils.isNotBlank(relationshipClass)
            && StringUtils.isNotBlank(division)) {

        final String loadSupervisorId = getSQL().getValue("supervisor/load")
                + " WHERE supervisors.Active = true AND" + " supervisors.ReferenceGUID = ? AND"
                + " relationshiptype.Value <= ? AND" + " relationshiptype.Class = ? AND"
                + " relationshiptype.Security = ?" + " ORDER BY relationshiptype.Value LIMIT 1";

        final BuilderBean loadDetails = new BuilderBean();
        loadDetails.setParameter("SUPERVISOR_PERSONOBJ", true);

        try {
            supervisor = (SupervisorBean) this.getJdbcTemplateReader().queryForObject(loadSupervisorId,
                    new Object[] { referenceGUID, hierarchy, relationshipClass, division }, new RowMapper() {
                        public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                            return loadSupervisor(rs, loadDetails);
                        }
                    });

        } catch (IncorrectResultSizeDataAccessException ie) {
            dataLogger.debug("No results found for search: " + ie.getMessage());
        }
    }
    return supervisor;
}

From source file:com.sfs.whichdoctor.dao.ItemDAOImpl.java

/**
 * Load the ItemBean for the supplied ItemId.
 *
 * @param itemId the item id//from ww w . jav a2 s  .co m
 * @param groupClassVal the group class value
 *
 * @return the item bean
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final ItemBean load(final int itemId, final String groupClassVal) throws WhichDoctorDaoException {

    String groupClass = "Members";
    if (groupClassVal != null) {
        groupClass = groupClassVal;
    }

    ItemBean item = null;

    dataLogger.info("Getting itemId:" + itemId);

    final String loadSQL = getLoadSQL(groupClass) + " AND items.ItemId = ?";

    try {
        item = (ItemBean) this.getJdbcTemplateReader().queryForObject(loadSQL, new Object[] { itemId },
                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());
    }
    return item;
}

From source file:com.sfs.whichdoctor.dao.ItemDAOImpl.java

/**
 * Load the referenced ItemBean for the supplied ReferenceGUID/Object1GUID pair.
 *
 * @param referenceGUID the reference id
 * @param object1GUID the object1 guid//from w w  w .j  a va  2 s. c  o m
 * @param groupClassVal the group class value
 *
 * @return the item bean
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final ItemBean loadReference(final int referenceGUID, final int object1GUID, final String groupClassVal)
        throws WhichDoctorDaoException {

    String groupClass = "Members";
    if (groupClassVal != null) {
        groupClass = groupClassVal;
    }

    ItemBean item = null;

    dataLogger.info("Getting referenceGUID:" + referenceGUID);

    final String loadSql = getLoadSQL(groupClass) + " AND items.ReferenceGUID = ? AND items.Object1GUID = ?";

    try {
        item = (ItemBean) this.getJdbcTemplateReader().queryForObject(loadSql,
                new Object[] { referenceGUID, object1GUID }, 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());
    }
    return item;
}

From source file:com.sfs.whichdoctor.dao.AccreditationDAOImpl.java

/**
 * Gets the training summary.//from   www  .  ja v  a2s  . c  o m
 *
 * @param guid the guid
 * @param type the type
 *
 * @return the training summary
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
@SuppressWarnings("unchecked")
public final TreeMap<String, AccreditationBean[]> getTrainingSummary(final int guid, final String type)
        throws WhichDoctorDaoException {

    if (type == null) {
        throw new NullPointerException("Training type cannot be null");
    }

    dataLogger.info("Getting " + type + " Training Summary for Member GUID: " + guid);

    TreeMap<String, AccreditationBean[]> summary = new TreeMap<String, AccreditationBean[]>();

    Collection<AccreditationBean> accreditations = new ArrayList<AccreditationBean>();
    try {
        accreditations = this.getJdbcTemplateReader().query(this.getSQL().getValue("accreditation/loadSummary"),
                new Object[] { guid, type }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        AccreditationBean accreditation = new AccreditationBean();

                        accreditation.setAbbreviation(rs.getString("AccreditationTypeAbbreviation"));
                        accreditation.setAccreditationType(rs.getString("AccreditationType"));
                        accreditation.setSpecialtyType(rs.getString("SpecialtyTypeClass"));
                        accreditation.setSpecialtySubType(rs.getString("SpecialtyTypeName"));
                        accreditation.setSpecialtyTypeAbbreviation(rs.getString("SpecialtyTypeAbbreviation"));
                        accreditation.setCore(rs.getBoolean("Core"));
                        accreditation.setWeeksApproved(rs.getInt("WeeksApproved"));
                        accreditation.setWeeksCertified(rs.getInt("WeeksCertified"));

                        // The active flag holds whether the accreditation is excess
                        boolean active = true;

                        String trainingClass = rs.getString("TrainingClass");
                        if (StringUtils.contains(trainingClass, "nterrupted")
                                || StringUtils.contains(trainingClass, "ontinuing")) {
                            active = false;
                        }
                        accreditation.setActive(active);

                        return accreditation;
                    }
                });

    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for search: " + ie.getMessage());
    }

    for (AccreditationBean acrd : accreditations) {
        if (acrd.getActive()) {

            // Generate index key
            String specialtyAbbreviation = acrd.getAccreditationType();
            String specialtyTypeName = acrd.getSpecialtyType();
            if (StringUtils.isNotBlank(acrd.getAbbreviation())) {
                specialtyAbbreviation = acrd.getAbbreviation();
            }
            if (StringUtils.isNotBlank(acrd.getSpecialtySubType())) {
                specialtyTypeName = acrd.getSpecialtyType() + " - " + acrd.getSpecialtySubType();
            }
            String specialtyKey = specialtyAbbreviation + ": " + specialtyTypeName;

            AccreditationBean core = new AccreditationBean();
            core.setAbbreviation(acrd.getAbbreviation());
            core.setAccreditationType(acrd.getAccreditationType());
            core.setCore(true);
            core.setSpecialtyType(acrd.getSpecialtyType());
            core.setSpecialtySubType(acrd.getSpecialtySubType());
            core.setSpecialtyTypeAbbreviation(acrd.getSpecialtyTypeAbbreviation());

            AccreditationBean nonCore = new AccreditationBean();
            nonCore.setAbbreviation(acrd.getAbbreviation());
            nonCore.setAccreditationType(acrd.getAccreditationType());
            nonCore.setCore(false);
            nonCore.setSpecialtyType(acrd.getSpecialtyType());
            nonCore.setSpecialtySubType(acrd.getSpecialtySubType());
            nonCore.setSpecialtyTypeAbbreviation(acrd.getSpecialtyTypeAbbreviation());

            if (summary.containsKey(specialtyKey)) {
                // Specialty exists in TreeMap -> Get array and modify
                try {
                    AccreditationBean[] existing = summary.get(specialtyKey);
                    core = existing[0];
                    nonCore = existing[1];
                } catch (Exception e) {
                    dataLogger.error("Error loading existing training summary item: " + e.getMessage());
                }
            }

            // Add to the relevant core/nonCore running totals
            if (acrd.getCore()) {
                core.setWeeksApproved(core.getWeeksApproved() + acrd.getWeeksApproved());
                core.setWeeksCertified(core.getWeeksCertified() + acrd.getWeeksCertified());
            } else {
                nonCore.setWeeksApproved(nonCore.getWeeksApproved() + acrd.getWeeksApproved());
                nonCore.setWeeksCertified(nonCore.getWeeksCertified() + acrd.getWeeksCertified());
            }

            // Set accreditation details
            AccreditationBean[] details = new AccreditationBean[] { core, nonCore };

            // Add accreditation to map
            summary.put(specialtyKey, details);
        }
    }
    return summary;
}

From source file:com.sfs.whichdoctor.analysis.AgedDebtorsAnalysisDAOImpl.java

/**
 * Load receipt map, where integer = guid of person/organisation.
 *
 * @param analysis the analysis/* ww  w.j av  a 2 s . c  o m*/
 * @return the hash map of receipts
 */
@SuppressWarnings("unchecked")
private HashMap<Integer, ReceiptBean> loadLastReceipts(final AgedDebtorsAnalysisBean analysis) {

    HashMap<Integer, ReceiptBean> lastReceipts = new HashMap<Integer, ReceiptBean>();

    StringBuffer sql = new StringBuffer();
    sql.append(this.getSQL().getValue("agedDebtors/lastReceipts"));
    sql.append(" WHERE ");
    sql.append(buildSqlWhere(analysis, "fs1.PersonId", "fs1.OrganisationId", false));
    sql.append(" GROUP BY fs1.PersonId");

    if (dataLogger.isDebugEnabled()) {
        dataLogger.debug("SQL: " + sql.toString());
    }

    Collection<ReceiptBean> receipts = new ArrayList<ReceiptBean>();

    try {
        receipts = this.getJdbcTemplateReader().query(sql.toString(), new Object[] {}, new RowMapper() {
            public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {

                ReceiptBean receipt = new ReceiptBean();

                receipt.setGUID(rs.getInt("Id"));
                receipt.setAbbreviation(rs.getString("Abbreviation"));
                receipt.setNumber(rs.getString("Number"));
                receipt.setPersonId(rs.getInt("PersonId"));
                receipt.setOrganisationId(rs.getInt("OrganisationId"));
                receipt.setNetValue(rs.getDouble("NetValue"));

                try {
                    receipt.setIssued(rs.getDate("Issued"));
                } catch (SQLException sqe) {
                    dataLogger.error("Error loading issued date: " + sqe.getMessage());
                }

                return receipt;
            }
        });

    } catch (IncorrectResultSizeDataAccessException ie) {
        // No results found for this search
        dataLogger.debug("No results found for this search: " + ie.getMessage());
    }

    for (ReceiptBean receipt : receipts) {
        if (receipt.getPersonId() > 0) {
            lastReceipts.put(receipt.getPersonId(), receipt);
        }
        if (receipt.getOrganisationId() > 0) {
            lastReceipts.put(receipt.getOrganisationId(), receipt);
        }
    }

    return lastReceipts;
}

From source file:com.sfs.whichdoctor.analysis.AgedDebtorsAnalysisDAOImpl.java

/**
 * Perform a lookup for a period based on the type of financial transaction.
 *
 * @param analysis the analysis/*from  w w  w.j  a v  a2s . c o  m*/
 * @param period the period
 * @param type the type
 * @return the collection
 */
@SuppressWarnings("unchecked")
private Collection<AgedDebtorsRecord> performLookup(final AgedDebtorsAnalysisBean analysis,
        final AgedDebtorsPeriod period, final String type) {

    Collection<AgedDebtorsRecord> records = new ArrayList<AgedDebtorsRecord>();

    String sqlEntry = "agedDebtors/debit";
    String personField = "invoice.PersonId";
    String organisationField = "invoice.OrganisationId";

    if (StringUtils.equalsIgnoreCase(type, "credit")) {
        sqlEntry = "agedDebtors/credit";
        personField = "credit.PersonId";
        organisationField = "credit.OrganisationId";
    }
    if (StringUtils.equalsIgnoreCase(type, "refund")) {
        sqlEntry = "agedDebtors/refund";
        personField = "credit.PersonId";
        organisationField = "credit.OrganisationId";
    }
    if (StringUtils.equalsIgnoreCase(type, "receipt")) {
        sqlEntry = "agedDebtors/receipt";
        personField = "payment.PersonId";
        organisationField = "payment.OrganisationId";
    }

    StringBuffer sql = new StringBuffer();
    sql.append(this.getSQL().getValue(sqlEntry));
    sql.append(buildSqlWhere(analysis, personField, organisationField, true));
    sql.append(" GROUP BY ");
    sql.append(personField);
    sql.append(", ");
    sql.append(organisationField);

    if (dataLogger.isDebugEnabled()) {
        dataLogger.debug("SQL: " + sql.toString());
        dataLogger.debug("Start date: " + period.getStartDate());
        dataLogger.debug("End date: " + period.getEndDate());
    }

    try {
        records = this.getJdbcTemplateReader().query(sql.toString(),
                new Object[] { period.getEndDate(), period.getStartDate() }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        AgedDebtorsRecord record = new AgedDebtorsRecord();
                        record.setPersonGUID(rs.getInt("PersonId"));
                        record.setOrganisationGUID(rs.getInt("OrganisationId"));
                        record.setOutstandingDebitValue(rs.getDouble("Value"));

                        return record;
                    }
                });

    } catch (IncorrectResultSizeDataAccessException ie) {
        // No results found for this search
        dataLogger.debug("No results found for this search: " + ie.getMessage());
    }
    return records;
}