UserDaoImpl implements UserDao { @SuppressWarnings("unchecked") @Override @Transactional public List<Integer> getAllUserIds() { return getSession().createQuery("SELECT user.id FROM User user").list(); }  @Autowired void setSessionFactory(SessionFactory sessionFactory); @Override @Transactional int getNumberOfUsers(); @SuppressWarnings("unchecked") @Override @Transactional List<Integer> getAllUserIds(); @Override @Transactional List<Integer> getAllUserIdsInRange(final int firstResult,
      final int maxResults); @Override @Transactional long getNumberOfStaleUsers(Date lastAccessTime); @Override @Transactional List<Integer> getStaleUserIdsInRange(final Date lastAccessTime, final int firstResult, final int maxResults); @Override @Transactional User getUserForId(int id); @Transactional @Override void saveOrUpdateUser(User user); @Override void saveOrUpdateUsers(User... users); @Override @Transactional void deleteUser(User user); @Override @Transactional int getNumberOfUserRoles(); @Override @Transactional int getNumberOfUsersWithRole(UserRole role); @Override @Transactional UserRole getUserRoleForName(String name); @Override @Transactional void saveOrUpdateUserRole(UserRole userRole); @SuppressWarnings("unchecked") @Override @Transactional List<String> getUserIndexKeyValuesForKeyType(String keyType); @Override @Transactional Integer getUserKeyCount(final String keyType); @Override @Transactional List<User> getUsersForKeyType(final int start, final int maxResults, final String keyType); @Transactional @Override UserIndex getUserIndexForId(UserIndexKey key); @Override void saveOrUpdateUserIndex(UserIndex userIndex); @Override @Transactional void deleteUserIndex(UserIndex index);  }
@Test @Transactional public void testGetAllUserIds() { Set<Integer> ids = new HashSet<Integer>(); for (int i = 0; i < 100; i++) { User userA = new User(); userA.setCreationTime(new Date()); userA.setProperties(new UserPropertiesV1()); _dao.saveOrUpdateUser(userA); ids.add(userA.getId()); } int n = _dao.getNumberOfUsers(); assertEquals(100, n); Set<Integer> retreivedIds = new HashSet<Integer>(); final int limit = 20; for (int i = 0; i < n; i += limit) { List<Integer> pageOfIds = _dao.getAllUserIdsInRange(i, limit); assertTrue(pageOfIds.size() <= limit); retreivedIds.addAll(pageOfIds); } assertEquals(ids, retreivedIds); }