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.ListManagerDAOImpl.java

/**
 * Load the list manager bean.//w  ww.  ja  va 2s . co m
 *
 * @return the list manager bean
 *
 * @throws SFSDaoException the SFS dao exception
 */
@SuppressWarnings("unchecked")
public final ListManagerBean load() throws SFSDaoException {

    ListManagerBean listManager = new ListManagerBean();

    try {
        Collection<ListTypeBean> options = this.getJdbcTemplateReader()
                .query(this.getSQL().getValue("listmanager/load"), new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        ListTypeBean lt = new ListTypeBean();

                        lt.setObjectType(rs.getString("ObjectType"));
                        lt.setClassName(rs.getString("ClassName"));
                        lt.setInstanceName(rs.getString("InstanceName"));
                        lt.setAbbreviation(rs.getString("Abbreviation"));
                        lt.setDescription(rs.getString("Description"));
                        lt.setValue(rs.getString("Value"));
                        lt.setSecurity(rs.getString("Security"));
                        lt.setLdapMapping(1, rs.getString("LdapMapping"));
                        lt.setLdapMapping(2, rs.getString("SecondLdapMapping"));
                        lt.setLdapMapping(3, rs.getString("ThirdLdapMapping"));
                        lt.setListType(rs.getString("ListType"));

                        return lt;
                    }
                });

        listManager.setListTypes(options);

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

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

/**
 * Save the UserPreferencesBean.//  w  w  w  .j  a  v  a2 s  .  com
 *
 * @param userPreferences the user preferences
 *
 * @throws SFSDaoException the SFS dao exception
 */
public final void save(final UserPreferencesBean userPreferences) throws SFSDaoException {
    if (userPreferences.getDN() == null) {
        throw new SFSDaoException("User DN cannot have a null value");
    }

    try {
        this.getJdbcTemplateWriter().update(this.getSQL().getValue("userPreferences/delete"),
                new Object[] { userPreferences.getDN() });

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

    for (String index : userPreferences.getOptions().keySet()) {
        String value = userPreferences.getOption(index);

        try {
            this.getJdbcTemplateWriter().update(this.getSQL().getValue("userPreferences/save"), new Object[] {
                    userPreferences.getDN(), index, value, userPreferences.getDN(), index, value });

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

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

/**
 * Used to get a IsbPayloadBean for the the specified ISB Payload Id.
 * Returns null if no isb message found//from  w  w w. j av a 2 s.c o m
 *
 * @param isbPayloadId the isb payload id
 *
 * @return the isb payload bean
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final IsbPayloadBean load(final int isbPayloadId) throws WhichDoctorDaoException {
    dataLogger.info("ISB payload id: " + isbPayloadId + " requested");

    IsbPayloadBean isbPayload = null;

    try {
        isbPayload = (IsbPayloadBean) this.getIsbJdbcTemplate().queryForObject(
                this.getSQL().getValue("isbpayload/loadId"), new Object[] { isbPayloadId }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadIsbPayloadBean(rs);
                    }
                });

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

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

/**
 * Used to get an IsbPayloadBean for the specified IsbMessageBean Id.
 *
 * @param isbMessageId the isb message id
 *
 * @return the isb payload bean/*from ww w  .j  ava  2s . c  om*/
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final IsbPayloadBean loadSiblingOf(final int isbMessageId) throws WhichDoctorDaoException {
    dataLogger.info("ISB payload with a parent id of : " + isbMessageId + " requested");

    IsbPayloadBean isbPayload = null;

    try {
        isbPayload = (IsbPayloadBean) this.getIsbJdbcTemplate().queryForObject(
                this.getSQL().getValue("isbpayload/loadParent"), new Object[] { isbMessageId },
                new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadIsbPayloadBean(rs);
                    }
                });

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

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

/**
 * Load the UserPreferencesBean for the supplied dn.
 *
 * @param dn the dn//from  w  ww .  j  a  v  a2  s . c  o  m
 *
 * @return the user preferences bean
 *
 * @throws SFSDaoException the SFS dao exception
 */
@SuppressWarnings("unchecked")
public final UserPreferencesBean load(final String dn) throws SFSDaoException {
    if (dn == null) {
        throw new SFSDaoException("Error: DN cannot be null");
    }
    if (dn.compareTo("") == 0) {
        throw new SFSDaoException("Error: DN cannot be an empty string");
    }

    UserPreferencesBean userPreferences = new UserPreferencesBean();
    userPreferences.setDN(dn);

    dataLogger.info("Loading privileges for: " + dn);

    try {
        Collection<String[]> indexValue = this.getJdbcTemplateReader().query(
                this.getSQL().getValue("userPreferences/load"), new Object[] { userPreferences.getDN() },
                new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        final String index = rs.getString("IndexValue");
                        final String value = rs.getString("Value");

                        return new String[] { index, value };
                    }
                });

        for (String[] keyPair : indexValue) {
            if (keyPair[0] != null) {
                userPreferences.setOption(keyPair[0], keyPair[1]);
            }
        }

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

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

/**
 * Load the cached user details.//  ww  w.j  a va 2s  . c  o  m
 *
 * @param dn the distinguished name of the user
 *
 * @return the user bean
 *
 * @throws SFSDaoException the SFS dao exception
 */
public final UserBean loadCached(final String dn) throws SFSDaoException {

    UserBean cachedUser = null;
    try {
        // Create a new entry as none exists...
        cachedUser = (UserBean) this.getJdbcTemplateReader().queryForObject(this.getSQL().getValue("user/load"),
                new Object[] { dn }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        UserBean loadedUser = new UserBean();
                        loadedUser.setDN(rs.getString("UserDn"));
                        loadedUser.setPreferredName(rs.getString("FirstName"));
                        loadedUser.setLastName(rs.getString("LastName"));
                        loadedUser.setEmail(rs.getString("Email"));

                        return loadedUser;
                    }
                });

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

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

/**
 * Record settings./*  w  w w . j a v  a  2  s.co  m*/
 *
 * @param settingsBean the settings bean
 *
 * @return true, if successful
 *
 * @throws Exception the exception
 */
private boolean recordSettings(final SettingsBean settingsBean) throws Exception {

    boolean success = false;

    final String xmlString = settingsBean.getXmlDocumentAsString();

    try {
        final int updateCount = this.getJdbcTemplateWriter().update(this.getSQL().getValue("settings/create"),
                new Object[] { settingsBean.getType(), xmlString, settingsBean.getType(), xmlString });

        if (updateCount > 0) {
            dataLogger.info("Menu saved to database");
            success = true;
        }
    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for this search: " + ie.getMessage());
    }
    return success;
}

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

/**
 * Load a FieldMapBean object based on the supplied fieldMapId value.
 *
 * @param fieldMapId the field map id/*  www .j ava 2s . co  m*/
 *
 * @return the field map bean
 *
 * @throws SFSDaoException the SFS dao exception
 */
public final FieldMapBean load(final int fieldMapId) throws SFSDaoException {
    if (fieldMapId == 0) {
        throw new SFSDaoException("FieldMapId value cannot be 0");
    }

    FieldMapBean fieldMap = null;

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

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

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

/**
 * Loads a menu xml document from the database and returns it within a
 * SettingsBean.// w  w  w .  ja  v a2 s .c  om
 *
 * @param type the type
 *
 * @return the settings bean
 *
 * @throws SFSDaoException the SFS dao exception
 */
public final SettingsBean loadSettings(final String type) throws SFSDaoException {

    if (type == null) {
        throw new SFSDaoException("The settings type cannot be null");
    }

    SettingsBean settingsBean = null;

    try {
        settingsBean = (SettingsBean) this.getJdbcTemplateReader().queryForObject(
                this.getSQL().getValue("settings/load"), new Object[] { type }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {

                        SettingsBean loadedSettings = new SettingsBean();
                        loadedSettings.setType(type);

                        Reader settingsStream = rs.getCharacterStream("Settings");
                        SAXBuilder builder = new SAXBuilder();
                        try {
                            loadedSettings.setXmlDocument(builder.build(settingsStream));
                            dataLogger.info("XML settings file parsed " + "successfully");
                        } catch (JDOMException jde) {
                            dataLogger.fatal("Error parsing XML settings: " + jde.getMessage());
                        } catch (IOException ioe) {
                            dataLogger.fatal("Error reading XML character " + "stream: " + ioe.getMessage());
                        }
                        return loadedSettings;
                    }
                });

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

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

/**
 * Load a map of FieldMapBeans based on the supplied map class and type
 * variables.//  w w  w . j av  a2  s. com
 *
 * @param mapClass the map class
 * @param mapType the map type
 *
 * @return the map< string, field map bean>
 *
 * @throws SFSDaoException the SFS dao exception
 */
@SuppressWarnings("unchecked")
public final Map<String, FieldMapBean> load(final String mapClass, final String mapType)
        throws SFSDaoException {
    if (mapClass == null) {
        throw new SFSDaoException("Error: field map class cannot be null");
    }
    if (mapClass.compareTo("") == 0) {
        throw new SFSDaoException("Error: field map class cannot be an " + "empty string");
    }
    if (mapType == null) {
        throw new NullPointerException("Error: field map type cannot " + "be null");
    }
    dataLogger.info("Field maps for: " + mapClass + " - " + mapType + " requested");

    Map<String, FieldMapBean> fieldHash = new HashMap<String, FieldMapBean>();

    Collection<FieldMapBean> fieldMaps = new ArrayList<FieldMapBean>();
    try {
        fieldMaps = this.getJdbcTemplateReader().query(this.getSQL().getValue("fieldMap/loadName"),
                new Object[] { mapClass, mapType }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        return loadFieldMap(rs);
                    }
                });

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

    for (FieldMapBean fieldMap : fieldMaps) {
        fieldHash.put(fieldMap.getName(), fieldMap);
    }
    return fieldHash;
}