Mybatis Mapper.xml 需要查询返回List

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.xinwei.process.dao.RoleServiceTypeMapper" >
  <resultMap id="BaseResultMap" type="com.xinwei.process.entity.RoleServiceType" >
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="role_id" property="roleId" jdbcType="INTEGER" />
    <result column="service_type" property="serviceType" jdbcType="VARCHAR" />
  </resultMap>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
    delete from tb_role_service_type
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.xinwei.process.entity.RoleServiceType" >
    insert into tb_role_service_type (id, role_id, service_type
      )
    values (#{id,jdbcType=BIGINT}, #{roleId,jdbcType=INTEGER}, #{serviceType,jdbcType=VARCHAR}
      )
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.xinwei.process.entity.RoleServiceType" >
    update tb_role_service_type
    set role_id = #{roleId,jdbcType=INTEGER},
      service_type = #{serviceType,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    select id, role_id, service_type
    from tb_role_service_type
    where id = #{id,jdbcType=BIGINT}
  </select>
  <select id="selectAll" resultMap="BaseResultMap" >
    select id, role_id, service_type
    from tb_role_service_type
  </select>

 <select id="selectServiceTypeListByRole"  resultType="java.lang.String">
    select service_type
    from tb_role_service_type
    where role_id = #{roleId,jdbcType=INTEGER}
  </select>

 

</mapper>


    原文作者:MyBatis
    原文地址: https://www.cnblogs.com/alamps/p/6442493.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞