我的目标是填补空缺 UserDto
pojo使用“usersmapper”mybatisMap器。
public class UserDto {
private String username;
private String password;
private List<String> authorities;
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
public Set<SimpleGrantedAuthority> getAuthorities() {
return authorities.stream()
.map(SimpleGrantedAuthority::new)
.collect(Collectors.toSet());
}
}
@Mapper
public interface UsersMapper {
@Select("SELECT users.username, users.password, role_authorities.authority " +
"FROM users " +
"JOIN role_members ON role_members.username = users.username " +
"AND users.username=#{username} " +
"JOIN role_authorities ON role_authorities.role_uuid = role_members.role_uuid")
Optional<UserDto> getUsers(String username);
}
这就是我直接运行sql语句的样子。
我的预期结果是:mybatis成功地填补了 UserDto
波乔。
我的实际结果是我得到了一个例外
org.springframework.security.authentication.InternalAuthenticationServiceException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 3
暂无答案!
目前还没有任何答案,快来回答吧!