数据库表
attr_id值为20的有两行数据
if (attrRespVo.getAttrType() == ProductAttrTypeEnum.ATTR_TYPE_BASE.getCode()) {
//根据attrId查询attr_Gruop_id在查询groupName
AttrAttrgroupRelationEntity entity = attrAttrgroupRelationDao.
selectOne(new QueryWrapper<AttrAttrgroupRelationEntity>().eq("attr_id", attrRespVo.getAttrId()));
if (entity != null && entity.getAttrGroupId() != null) {
AttrGroupEntity attrGroupEntity = attrGroupDao.selectById(entity.getAttrGroupId());
attrRespVo.setGroupName(attrGroupEntity.getAttrGroupName());
}
}
在service中,根据attr_Id查询AttrAttrgroupRelationEntity实体类时,查出来两个实体类,也就是数据库中对应那两行数据,所以就报了TooManyResultsException.
总结:TooManyResultsException是由于从数据库表中查出多条数据所导致。