Spring Mybatis 返回 List 和List>

时间:2022-08-21 10:32:21

如果返回List,resultType=”String”就可以了,如果需要返回List

 <select id="selectAllInnerUser" resultType="String">
select account_name
from user_account
where is_deleted=0 and user_type=0
</select>

2.

 <resultMap id="stringsResult" type="java.lang.String">
<result column="account_name" property="accountName" jdbcType="VARCHAR" />
</resultMap>
<select id="selectAllInnerUser" resultMap="stringsResult">
select account_name
from user_account
where is_deleted=0 and user_type=0
</select>

二、要返回map可以通过如下方式知道key和value

<resultMap type="HashMap" id="testMap">  
<result column="UA_INFO" property="key" />
<association property="value" resultMap="com.xxx.xxx.BaseResultMap"></association>
</resultMap>
<select id="getUaMapByTimestamp" parameterType="Map" resultMap="testMap">
</select>

下面的还未尝试!
或者List

<select id="getMyCredit"  parameterClass="java.util.Map" resultClass="java.util.HashMap">
</select>

这样设置返回类型为resultClass=”java.util.HashMap”,查询时执行queryForList
List