Collection使用问题

    xiaoxiao2021-03-25  20

    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 4

    到这个错误的原因就是因为你的查询方法中得到两个两个结果集,然而你的返回用了一个实体去接收,程序这个时候就不知道如何去分配了,很果断的报这个错,

    修改方法为使用一个list来接收就没有问题了。

    但是对于是返回多个字段的sql,需要使用bean进行封装后再放入collection中返回;

    也可以看下association,只是只能针对一对一的情况

    转载请注明原文地址: https://ju.6miu.com/read-155469.html

    最新回复(0)