Mybatis nested query error TooManyResultsException


        select
        <include refid="Base_Column_List"/>
        from sys_permission
        where id = -sharp{id,jdbcType=INTEGER}
    </select>
</mapper>

if you change dao to
List < SysRole > getRoleWithPermission (Integer id);
, three records are returned, and each role corresponds to a permission.

Mar.05,2021

because it is true that the sql statement finds three records
if you use < collection select= "> to find it, you can pass in only one value. So the result can only be one record.
if you use < collection resultMap >, mybatis will merge multiple checked results into collection by pressing the primary key id.


        </collection>
    </resultMap>
Menu