protected List<UserDetails> loadUsersByUsername(String username) {
		return getJdbcTemplate().query(getUsersByUsernameQuery(), new String[]{username},
				(rs, rowNum) -> {

					String userName = rs.getString(1);
					String password = rs.getString(2);
					boolean enabled = rs.getBoolean(3);

					boolean accLocked = false;
					boolean accExpired = false;
					boolean credsExpired = false;

					if (rs.getMetaData().getColumnCount() > 3) {
						//NOTE: acc_locked, acc_expired and creds_expired are also to be loaded
						accLocked = rs.getBoolean(4);
						accExpired = rs.getBoolean(5);
						credsExpired = rs.getBoolean(6);
					}
					return new User(userName, password, enabled, !accExpired, !credsExpired, !accLocked,
							AuthorityUtils.NO_AUTHORITIES);
				});
	}