Package org.springframework.dao

Examples of org.springframework.dao.IncorrectResultSizeDataAccessException


        assertThat((User)result, is(sameInstance(authUser)));
    }

    @Test(expected = UsernameNotFoundException.class)
    public void loadByUsername_invalid_exception() {
        expect(userRepository.getByUsername(USER_NAME)).andThrow(new IncorrectResultSizeDataAccessException(1));
        replay(userRepository);

        service.setAuthenticatedUser(USER_ID);
    }
View Full Code Here


    public boolean userExists(String username) {
        List<String> users = getJdbcTemplate().queryForList(userExistsSql, new String[] {username}, String.class);

        if (users.size() > 1) {
            throw new IncorrectResultSizeDataAccessException("More than one user found with name '" + username + "'", 1);
        }

        return users.size() == 1;
    }
View Full Code Here

                    } catch (PartialResultException e) {
                        logger.info("Ignoring PartialResultException");
                    }

                    if (results.size() == 0) {
                        throw new IncorrectResultSizeDataAccessException(1, 0);
                    }

                    if (results.size() > 1) {
                        throw new IncorrectResultSizeDataAccessException(1, results.size());
                    }

                    return results.toArray()[0];
                }
            });
View Full Code Here

    int size = (results != null ? results.size() : 0);
    if (size == 0) {
      return null;
    }
    if (results.size() > 1) {
      throw new IncorrectResultSizeDataAccessException(1, size);
    }
    return results.iterator().next();
  }
View Full Code Here

    int size = (results != null ? results.size() : 0);
    if (size == 0) {
      throw new EmptyResultDataAccessException(1);
    }
    if (results.size() > 1) {
      throw new IncorrectResultSizeDataAccessException(1, size);
    }
    return results.iterator().next();
  }
View Full Code Here

    int size = (results != null ? results.size() : 0);
    if (size == 0) {
      return null;
    }
    if (!CollectionUtils.hasUniqueObject(results)) {
      throw new IncorrectResultSizeDataAccessException(1, size);
    }
    return results.iterator().next();
  }
View Full Code Here

    int size = (results != null ? results.size() : 0);
    if (size == 0) {
      throw new EmptyResultDataAccessException(1);
    }
    if (!CollectionUtils.hasUniqueObject(results)) {
      throw new IncorrectResultSizeDataAccessException(1, size);
    }
    return results.iterator().next();
  }
View Full Code Here

    }
    if (ex instanceof NoResultException) {
      return new EmptyResultDataAccessException(ex.getMessage(), 1, ex);
    }
    if (ex instanceof NonUniqueResultException) {
      return new IncorrectResultSizeDataAccessException(ex.getMessage(), 1, ex);
    }
    if (ex instanceof QueryTimeoutException) {
      return new org.springframework.dao.QueryTimeoutException(ex.getMessage(), ex);
    }
    if (ex instanceof LockTimeoutException) {
View Full Code Here

    if (ex instanceof QueryException) {
      return new HibernateQueryException((QueryException) ex);
    }
    if (ex instanceof NonUniqueResultException) {
      return new IncorrectResultSizeDataAccessException(ex.getMessage(), 1, ex);
    }
    if (ex instanceof NonUniqueObjectException) {
      return new DuplicateKeyException(ex.getMessage(), ex);
    }
    if (ex instanceof PropertyValueException) {
View Full Code Here

   * @throws DataAccessException a corresponding exception,
   * by default an IncorrectResultSizeDataAccessException
   * @see org.springframework.dao.IncorrectResultSizeDataAccessException
   */
  protected void handleMultipleRowsFound() throws DataAccessException {
    throw new IncorrectResultSizeDataAccessException(
        "LobStreamingResultSetExtractor found multiple rows in database", 1);
  }
View Full Code Here

TOP

Related Classes of org.springframework.dao.IncorrectResultSizeDataAccessException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.