HMIT_Frank
2016-03-05 03:14
采纳率: 38.5%
浏览 3.4k
已采纳

mybatis 查询返回map<id,javabean>

mybatis 查询返回map,key为某一字段,value为实体类

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • HMIT_Frank 2016-11-11 04:28
    已采纳

    --- @MapKey

    已采纳该答案
    打赏 评论
  • 毕小宝 2016-03-05 03:32

    直接配置查询返回值类型为resultMap就可以了啊。

    打赏 评论
  • 天杪 2019-07-24 18:58

    楼上说的很对,

     <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.Enterprise">
            <id column="id" property="id" />
            <result column="e_business_name" property="eBusinessName" />
            <result column="e_telephone" property="eTelephone" />
            <result column="e_websiteurl" property="eWebsiteurl" />
            <result column="e_mailbox" property="eMailbox" />
            <result column="e_address" property="eAddress" />
            <result column="e_introduction" property="eIntroduction" />
            <result column="e_creation_time" property="eCreationTime" />
            <result column="e_creating_users" property="eCreatingUsers" />
            <result column="e_release_time" property="eReleaseTime" />
            <result column="e_release_users" property="eReleaseUsers" />
            <result column="e_edit_users" property="eEditUsers" />
            <result column="e_edit_time" property="eEditTime" />
        </resultMap>
    
      <select id="list" resultMap="BaseResultMap">
            select
            *
             from bw_enterprise
            <if test="condition != null and condition != ''">
                where e_business_name like CONCAT('%',#{condition},'%')
            </if>
        </select>
    
    
    打赏 评论

相关推荐 更多相似问题