mybatis 返回 对象中属性中包含List<String>
1.实体
@Data
public class User {
private Long userId;
private String phone;
private String username;
private List<String> roles;
}2.resultMap
<resultMap id="BaseResultMap" type="com.moon.model.User" >
<id column="user_id" property="userId" jdbcType="BIGINT" />
<result column="phone" property="phone" jdbcType="VARCHAR" />
<result column="username" property="username" jdbcType="VARCHAR" />
<collection property="roles" ofType="java.lang.String">
<constructor>
<arg column="roles"/>
</constructor>
</collection>
</resultMap>3.sql 语句
<select id="selectByPhone" resultMap="BaseResultMap" parameterType="java.lang.String" >
SELECT a.user_id,a.phone,a.username,c.role as roles
FROM b_user a , b_user_role b , b_role c
WHERE a.user_id = b.user_id AND b.role_id = c.role_id and a.phone = #{phone,jdbcType=VARCHAR}
</select> 相关推荐
Lzs 2020-10-23
聚合室 2020-11-16
零 2020-09-18
Justhavefun 2020-10-22
ChaITSimpleLove 2020-10-06
周游列国之仕子 2020-09-15
afanti 2020-09-16
88234852 2020-09-15
YClimb 2020-09-15
风雨断肠人 2020-09-04
卖口粥湛蓝的天空 2020-09-15
stulen 2020-09-15
pythonxuexi 2020-09-06
abfdada 2020-08-26
梦的天空 2020-08-25