mybatis 查询返回map<id,javabean>

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

3个回答

--- @MapKey

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

楼上说的很对,

 <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>

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问