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.dao.ObjectTypeDAOImpl.java

/**
 * Load an ObjectTypeBean for the supplied id.
 *
 * @param objectTypeId the object type id
 *
 * @return the object type bean/*  w ww .j ava  2 s  .co m*/
 *
 * @throws SFSDaoException the SFS dao exception
 */
@SuppressWarnings("unchecked")
public final ObjectTypeBean load(final int objectTypeId) throws SFSDaoException {

    if (objectTypeId == 0) {
        throw new SFSDaoException("ObjectTypeId value cannot be 0");
    }

    ObjectTypeBean objectType = null;

    try {
        objectType = (ObjectTypeBean) this.getJdbcTemplateReader().queryForObject(
                this.getSQL().getValue("objectType/loadId"), new Object[] { objectTypeId }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadObject(rs);
                    }
                });

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

From source file:com.sfs.dao.ObjectTypeDAOImpl.java

/**
 * Load a collection of ObjectTypeBeans.
 *
 * @param type the type//from w  ww .  j  a v a  2 s . com
 *
 * @return the collection< object type bean>
 *
 * @throws SFSDaoException the SFS dao exception
 */
@SuppressWarnings("unchecked")
public final Collection<ObjectTypeBean> load(final String type) throws SFSDaoException {

    if (StringUtils.isBlank(type)) {
        throw new SFSDaoException("Error: type cannot be an empty string");
    }
    dataLogger.info("List items for: " + type + " requested");

    Collection<ObjectTypeBean> listItems = new ArrayList<ObjectTypeBean>();

    try {
        listItems = this.getJdbcTemplateReader().query(this.getSQL().getValue("objectType/load"),
                new Object[] { type }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadObject(rs);
                    }
                });

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

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

/**
 * Loads an array of groups based on the submitted voteNumber and year.
 *
 * @param voteNumber the vote number/*from   w  ww . ja  v  a  2 s .  co  m*/
 * @param year the year
 *
 * @return the collection< group bean>
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
@SuppressWarnings("unchecked")
public final Collection<GroupBean> findElections(final int voteNumber, final int year)
        throws WhichDoctorDaoException {

    if (year == 0) {
        throw new WhichDoctorDaoException("Sorry a valid year is required");
    }

    Collection<GroupBean> elections = new ArrayList<GroupBean>();

    dataLogger.info("Loading elections for: " + voteNumber + "/" + year);

    /* Identify the referenceGUID from the vote number and year */
    int referenceGUID = PersonBean.getVoterGUID(voteNumber, year);

    TreeMap<Integer, Integer> electionList = new TreeMap<Integer, Integer>();

    try {
        Collection<Integer> guids = this.getJdbcTemplateReader().query(
                this.getSQL().getValue("vote/findPossibleElections"), new Object[] { year, referenceGUID },
                new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return rs.getInt("GUID");
                    }
                });

        for (Integer guid : guids) {
            electionList.put(guid, guid);
        }
    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for this search: " + ie.getMessage());
    }

    try {
        Collection<Integer> guids = this.getJdbcTemplateReader().query(
                this.getSQL().getValue("vote/findVotedElections"), new Object[] { year, referenceGUID },
                new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return rs.getInt("GUID");
                    }
                });

        for (Integer guid : guids) {
            if (electionList.containsKey(guid)) {
                // This election has been voted for already, remove it from the list
                electionList.remove(guid);
            }
        }
    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for this search: " + ie.getMessage());
    }

    if (electionList.size() > 0) {
        // An unvoted election exists in the map, perform a group search to load it
        Collection<Object> guidCollection = new ArrayList<Object>();
        for (Integer groupGUID : electionList.keySet()) {
            guidCollection.add(groupGUID);
        }
        try {
            SearchBean search = this.searchDAO.initiate("group", null);
            search.setLimit(0);
            search.setOrderColumn("groups.Weighting");
            search.setOrderColumn2("groups.Name");
            search.setSearchArray(guidCollection, "Unvoted list of elections");

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

            SearchResultsBean results = this.searchDAO.search(search, loadDetails);

            if (results != null) {
                // Add each group to the election array
                for (Object result : results.getSearchResults()) {
                    GroupBean election = (GroupBean) result;
                    elections.add(election);
                }
            }
        } catch (Exception e) {
            dataLogger.error("Error performing election search: " + e.getMessage());
            throw new WhichDoctorDaoException("Error performing election search: " + e.getMessage());
        }
    }
    return elections;
}

From source file:com.sfs.dao.ObjectTypeDAOImpl.java

/**
 * Delete an object type./*from  w  w w.ja  v a 2s .  c  om*/
 *
 * @param objectType the object type
 * @param checkUser the check user
 * @param privileges the privileges
 *
 * @return true, if successful
 *
 * @throws SFSDaoException the SFS dao exception
 */
public final boolean delete(final ObjectTypeBean objectType, final UserBean checkUser,
        final PrivilegesBean privileges) throws SFSDaoException {

    if (objectType.getObjectTypeId() == 0) {
        throw new SFSDaoException("ObjectType requires a vaild " + "ObjectTypeId number");
    }
    if (!privileges.getPrivilege(checkUser, "objectType", "delete")) {
        throw new SFSDaoException("Insufficient user credentials to delete " + "object type");
    }

    boolean success = false;

    try {
        int deleteCount = this.getJdbcTemplateWriter().update(this.getSQL().getValue("objectType/delete"),
                new Object[] { objectType.getObjectTypeId() });

        if (deleteCount > 0) {
            dataLogger.info(checkUser.getDN() + " successfully deleted " + "object type");
            success = true;
        }

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

From source file:com.sfs.dao.ObjectTypeDAOImpl.java

/**
 * Load the class name for ObjectTypeBean using the supplied abbreviation.
 *
 * @param object the object/*w w  w  .  j  a va2 s.  c  o m*/
 * @param abbreviation the abbreviation associated with the object
 *
 * @return the class name
 *
 * @throws SFSDaoException the SFS dao exception
 */
@SuppressWarnings("unchecked")
public final String load(final String object, final String abbreviation) throws SFSDaoException {

    String className = "";

    Collection<String> classNames = new ArrayList<String>();

    try {
        classNames = this.getJdbcTemplateReader().query(this.getSQL().getValue("objectType/loadClassName"),
                new String[] { object, abbreviation.toUpperCase() }, new RowMapper() {
                    public String mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        String name = rs.getString("Class");
                        return name;
                    }
                });

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

    if (classNames != null) {
        for (String name : classNames) {
            if (StringUtils.isNotBlank(name)) {
                className = name;
            }
        }
    }
    return className;
}

From source file:com.sfs.dao.ObjectTypeDAOImpl.java

/**
 * Load an ObjectTypeBean for the supplied parameters.
 *
 * @param object the object//  w  w  w .  ja v a 2 s . c  o  m
 * @param objectName the object name
 * @param objectClass the object class
 *
 * @return the object type bean
 *
 * @throws SFSDaoException the SFS dao exception
 */
@SuppressWarnings("unchecked")
public final ObjectTypeBean load(final String object, final String objectName, final String objectClass)
        throws SFSDaoException {
    if (object == null) {
        throw new SFSDaoException("Object definition cannot be null");
    }
    if (objectName == null) {
        throw new SFSDaoException("Object Name cannot be null");
    }
    if (objectClass == null) {
        throw new SFSDaoException("Object Class canot be null");
    }

    ObjectTypeBean objectType = null;

    try {
        objectType = (ObjectTypeBean) this.getJdbcTemplateReader().queryForObject(
                this.getSQL().getValue("objectType/loadType"), new Object[] { object, objectName, objectClass },
                new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadObject(rs);
                    }
                });

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

    if (objectType == null) {
        throw new SFSDaoException("No objecttype found");
    }
    return objectType;
}

From source file:com.sfs.dao.ObjectTypeDAOImpl.java

/**
 * Load an ObjectTypeBean for the supplied parameters.
 *
 * @param object the object//  www . j a  v  a 2  s  . c o m
 * @param objectAbbreviation the object abbreviation
 * @param objectName the object name
 * @param objectClass the object class
 *
 * @return the object type bean
 *
 * @throws SFSDaoException the SFS dao exception
 */
@SuppressWarnings("unchecked")
public final ObjectTypeBean load(final String object, final String objectAbbreviation, final String objectName,
        final String objectClass) throws SFSDaoException {
    if (object == null) {
        throw new SFSDaoException("Object definition cannot be null");
    }
    if (objectAbbreviation == null) {
        throw new SFSDaoException("Object Abbreviation cannot be null");
    }
    if (objectName == null) {
        throw new SFSDaoException("Object Name cannot be null");
    }
    if (objectClass == null) {
        throw new SFSDaoException("Object Class canot be null");
    }

    ObjectTypeBean objectType = null;

    try {
        objectType = (ObjectTypeBean) this.getJdbcTemplateReader().queryForObject(
                this.getSQL().getValue("objectType/loadTypeAbbreviation"),
                new Object[] { object, objectAbbreviation, objectName, objectClass }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadObject(rs);
                    }
                });

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

    if (objectType == null) {
        throw new SFSDaoException("No objecttype found");
    }
    return objectType;
}

From source file:com.sfs.dao.ObjectTypeDAOImpl.java

/**
 * Modify an object type.//from  w w  w .  ja va 2s.  c  o m
 *
 * @param objectType the object type
 * @param checkUser the check user
 * @param privileges the privileges
 *
 * @return true, if successful
 *
 * @throws SFSDaoException the SFS dao exception
 */
public final boolean modify(final ObjectTypeBean objectType, final UserBean checkUser,
        final PrivilegesBean privileges) throws SFSDaoException {

    if (objectType.getObjectTypeId() == 0) {
        throw new SFSDaoException("ObjectTypeId cannot be 0");
    }
    if (objectType.getName() == null) {
        objectType.setName("");
    }
    if (StringUtils.isBlank(objectType.getClassName())) {
        throw new SFSDaoException("ObjectType cannot have an empty string " + "for a class");
    }
    if (!privileges.getPrivilege(checkUser, "objectType", "modify")) {
        throw new SFSDaoException("Insufficient user credentials to edit " + "object type");
    }

    boolean success = false;

    try {
        Calendar calendar = Calendar.getInstance();
        Timestamp currentTime = new Timestamp(calendar.getTimeInMillis());

        int updateCount = this.getJdbcTemplateWriter().update(this.getSQL().getValue("objectType/modify"),
                new Object[] { objectType.getName(), objectType.getClassName(), objectType.getAbbreviation(),
                        objectType.getValue(), objectType.getSecurity(), objectType.getLdapMapping(1),
                        objectType.getLdapMapping(2), objectType.getLdapMapping(3), currentTime,
                        checkUser.getDN(), objectType.getObjectTypeId() });

        if (updateCount > 0) {
            dataLogger.info(checkUser.getDN() + " successfully updated " + "object type");
            success = true;
        }

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

From source file:com.sfs.dao.ObjectTypeDAOImpl.java

/**
 * Creates an object type.//  w w  w. j a v a 2s .  com
 *
 * @param objectType the object type
 * @param checkUser the check user
 * @param privileges the privileges
 *
 * @return true, if successful
 *
 * @throws SFSDaoException the SFS dao exception
 */
public final boolean create(final ObjectTypeBean objectType, final UserBean checkUser,
        final PrivilegesBean privileges) throws SFSDaoException {

    if (objectType.getObject() == null) {
        throw new SFSDaoException("ObjectType cannot have a null object type");
    }
    if (objectType.getName() == null) {
        objectType.setName("");
    }
    if (StringUtils.isBlank(objectType.getObject())) {
        throw new SFSDaoException("ObjectType cannot have an empty string " + "for its object type");
    }
    if (StringUtils.isBlank(objectType.getClassName())) {
        throw new SFSDaoException("ObjectType cannot have an empty string " + "for a class");
    }
    if (!privileges.getPrivilege(checkUser, "objectType", "create")) {
        throw new SFSDaoException("Insufficient user credentials to create new object type");
    }

    boolean success = false;

    try {
        Calendar calendar = Calendar.getInstance();
        Timestamp currentTime = new Timestamp(calendar.getTimeInMillis());

        int insertCount = this.getJdbcTemplateWriter().update(this.getSQL().getValue("objectType/create"),
                new Object[] { objectType.getObject(), objectType.getName(), objectType.getClassName(),
                        objectType.getAbbreviation(), objectType.getValue(), objectType.getSecurity(),
                        objectType.getLdapMapping(1), objectType.getLdapMapping(2),
                        objectType.getLdapMapping(3), currentTime, checkUser.getDN() });

        if (insertCount > 0) {
            dataLogger.info(checkUser.getDN() + " successfully created " + "object type");
            success = true;
        }

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

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

/**
 * Load the AccreditationBean.//from  w ww .j  av  a 2 s.co  m
 *
 * @param accreditationId the accreditation id
 *
 * @return the accreditation bean
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final AccreditationBean load(final int accreditationId) throws WhichDoctorDaoException {
    dataLogger.info("Getting accreditationId:" + accreditationId);

    final String loadAccreditationId = getSQL().getValue("accreditation/load")
            + " WHERE accreditation.AccreditationId = ?";

    AccreditationBean accreditation = null;

    try {
        accreditation = (AccreditationBean) this.getJdbcTemplateReader().queryForObject(loadAccreditationId,
                new Object[] { accreditationId }, 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 accreditation;
}