我正在尝试从数据库检索值,但无法获取所有值。我正进入(状态TooManyResultsException
.
映射器接口
这是我正在调用的映射器接口。
public interface ITranslatorDAO
{
Map<String, Map<String, String>> translate();
}
映射器.xml
这部分是我针对数据库运行的 SQL,它有 190 行。我想检索所有行,但它抛出异常,如下所述。
<select id="translate" resultType="map">
SELECT
section,
data,
translation
FROM
web_data..wd_ofx_translate
ORDER BY
section,
data,
translation
</select>
异常回溯
Exception in thread "main" org.mybatis.spring.MyBatisSystemException:
nested exception is org.apache.ibatis.exceptions.TooManyResultsException:
Expected one result (or null) to be returned by selectOne(), but found: 190
你应该添加@MapKey来告诉mybatis你想要表中的哪一列作为映射的键,例如使用节列作为映射的键:
public interface ITranslatorDAO{
@MapKey("section")
Map<String, Map<String, String>> translate();
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)