Example usage for org.springframework.dao IncorrectResultSizeDataAccessException getActualSize

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

Introduction

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

Prototype

public int getActualSize() 

Source Link

Document

Return the actual result size (or -1 if unknown).

Usage

From source file:org.ohmage.query.impl.CampaignQueries.java

public String getName(String campaignId) throws DataAccessException {
    try {/* w  w w.  j  a v  a 2  s .  c o  m*/
        return getJdbcTemplate().queryForObject(SQL_GET_NAME, new Object[] { campaignId }, String.class);
    } catch (org.springframework.dao.IncorrectResultSizeDataAccessException e) {
        if (e.getActualSize() > 1) {
            throw new DataAccessException("Multiple campaigns have the same unique identifier.", e);
        }

        return null;
    } catch (org.springframework.dao.DataAccessException e) {
        throw new DataAccessException(
                "Error executing SQL '" + SQL_GET_NAME + "' with parameter: " + campaignId, e);
    }
}

From source file:org.ohmage.query.impl.CampaignQueries.java

public String getDescription(String campaignId) throws DataAccessException {
    try {/*from w ww .j a va2 s  .com*/
        return getJdbcTemplate().queryForObject(SQL_GET_DESCRIPTION, new Object[] { campaignId }, String.class);
    } catch (org.springframework.dao.IncorrectResultSizeDataAccessException e) {
        if (e.getActualSize() > 1) {
            throw new DataAccessException("Multiple campaigns have the same unique identifier.", e);
        }

        return null;
    } catch (org.springframework.dao.DataAccessException e) {
        throw new DataAccessException(
                "Error executing SQL '" + SQL_GET_DESCRIPTION + "' with parameter: " + campaignId, e);
    }
}

From source file:org.ohmage.query.impl.CampaignQueries.java

public String getXml(String campaignId) throws DataAccessException {
    try {// w w  w .  java 2  s. c om
        return getJdbcTemplate().queryForObject(SQL_GET_XML, new Object[] { campaignId }, String.class);
    } catch (org.springframework.dao.IncorrectResultSizeDataAccessException e) {
        if (e.getActualSize() > 1) {
            throw new DataAccessException("Multiple campaigns have the same unique identifier.", e);
        }

        return null;
    } catch (org.springframework.dao.DataAccessException e) {
        throw new DataAccessException("Error executing SQL '" + SQL_GET_XML + "' with parameter: " + campaignId,
                e);
    }
}

From source file:org.ohmage.query.impl.CampaignQueries.java

public String getIconUrl(String campaignId) throws DataAccessException {
    try {/*from w w  w . j  a  v a2 s . c o m*/
        return getJdbcTemplate().queryForObject(SQL_GET_ICON_URL, new Object[] { campaignId }, String.class);
    } catch (org.springframework.dao.IncorrectResultSizeDataAccessException e) {
        if (e.getActualSize() > 1) {
            throw new DataAccessException("Multiple campaigns have the same unique identifier.", e);
        }

        return null;
    } catch (org.springframework.dao.DataAccessException e) {
        throw new DataAccessException(
                "Error executing SQL '" + SQL_GET_ICON_URL + "' with parameter: " + campaignId, e);
    }
}

From source file:org.ohmage.query.impl.CampaignQueries.java

public Campaign.PrivacyState getCampaignPrivacyState(String campaignId) throws DataAccessException {
    try {/*  ww  w . j av  a  2 s  .co m*/
        return Campaign.PrivacyState.getValue(getJdbcTemplate().queryForObject(SQL_GET_PRIVACY_STATE,
                new Object[] { campaignId }, String.class));
    } catch (org.springframework.dao.IncorrectResultSizeDataAccessException e) {
        if (e.getActualSize() > 1) {
            throw new DataAccessException("Multiple campaigns have the same unique identifier.", e);
        }

        return null;
    } catch (org.springframework.dao.DataAccessException e) {
        throw new DataAccessException(
                "Error executing SQL '" + SQL_GET_PRIVACY_STATE + "' with parameter: " + campaignId, e);
    }
}

From source file:org.ohmage.query.impl.CampaignQueries.java

public Campaign.RunningState getCampaignRunningState(String campaignId) throws DataAccessException {
    try {/*from w ww.java2  s.  c o m*/
        return Campaign.RunningState.getValue(getJdbcTemplate().queryForObject(SQL_GET_RUNNING_STATE,
                new Object[] { campaignId }, String.class));
    } catch (org.springframework.dao.IncorrectResultSizeDataAccessException e) {
        if (e.getActualSize() > 1) {
            throw new DataAccessException("Multiple campaigns have the same unique identifier.", e);
        }

        return null;
    } catch (org.springframework.dao.DataAccessException e) {
        throw new DataAccessException(
                "Error executing SQL '" + SQL_GET_PRIVACY_STATE + "' with parameter: " + campaignId, e);
    }
}

From source file:org.ohmage.query.impl.CampaignQueries.java

public DateTime getCreationTimestamp(String campaignId) throws DataAccessException {
    try {//from  w ww  . j a v a 2s. c o  m
        return new DateTime(((Timestamp) getJdbcTemplate().queryForObject(SQL_GET_CREATION_TIMESTAMP,
                new Object[] { campaignId }, Timestamp.class)).getTime());
    } catch (org.springframework.dao.IncorrectResultSizeDataAccessException e) {
        if (e.getActualSize() > 1) {
            throw new DataAccessException("Multiple campaigns have the same unique identifier.", e);
        }

        return null;
    } catch (org.springframework.dao.DataAccessException e) {
        throw new DataAccessException(
                "Error executing SQL '" + SQL_GET_CREATION_TIMESTAMP + "' with parameter: " + campaignId, e);
    }
}

From source file:org.ohmage.query.impl.UserQueries.java

public Date getRegistrationRequestedDate(final String registrationId) throws DataAccessException {

    try {//from   w ww . j av  a2 s  .c om
        return new Date(getJdbcTemplate().queryForLong(SQL_GET_REGISTRATION_REQUEST_TIME,
                new Object[] { registrationId }));
    } catch (org.springframework.dao.IncorrectResultSizeDataAccessException e) {
        if (e.getActualSize() == 0) {
            return null;
        } else {
            throw new DataAccessException("Multiple results were returned for the request timestamp.");
        }
    } catch (org.springframework.dao.DataAccessException e) {
        throw new DataAccessException("Error executing SQL '" + SQL_GET_REGISTRATION_REQUEST_TIME
                + "' with parameter: " + registrationId, e);
    }
}

From source file:org.ohmage.query.impl.UserQueries.java

public Date getRegistrationAcceptedDate(final String registrationId) throws DataAccessException {

    try {// www.ja va 2s  .c  o  m
        Long acceptedLong = getJdbcTemplate().queryForLong(SQL_GET_REGISTRATION_ACCEPTED_TIME,
                new Object[] { registrationId });

        // This is what SQL returns when it is SQL NULL.
        if (acceptedLong == 0) {
            return null;
        } else {
            return new Date(acceptedLong);
        }
    } catch (org.springframework.dao.IncorrectResultSizeDataAccessException e) {
        if (e.getActualSize() == 0) {
            return null;
        } else {
            throw new DataAccessException("Multiple results were returned for the accepted timestamp.");
        }
    } catch (org.springframework.dao.DataAccessException e) {
        throw new DataAccessException("Error executing SQL '" + SQL_GET_REGISTRATION_ACCEPTED_TIME
                + "' with parameter: " + registrationId, e);
    }
}