ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

mybatis的association 一对一单向关联

2022-08-31 15:34:45  阅读:166  来源: 互联网

标签:name vol 单向 private vt mybatis id association volunteer


  01、基础类

public class VolIntegral extends BaseEntity
{
    private static final long serialVersionUID = 1L;
private Long inId;
@Excel(name = "志愿者id") private Long vtId; @Excel(name = "志愿者积分值") private Long inIntegralNum; private Volunteer volunteer; public Volunteer getVolunteer() { return volunteer; } public void setVolunteer(Volunteer volunteer) { this.volunteer = volunteer; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("inId", getInId()) .append("vtName",getVtName()) .append("volunteer", getVolunteer()) .toString(); } }
  <!--selectVolIntegralListOverride   积分列表的接口重写-->
 <resultMap type="com.biaogan.system.domain.Volunteer" id="VolunteerMap">
        <id property="vtId" column="vt_id"/>
        <result property="vtName" column="vt_name"/>
        <result property="vtIntegralCount" column="vt_integral_count"/>
 </resultMap>
    <resultMap type="com.biaogan.system.domain.VolIntegral" id="VolIntegralMap">
        <id property="inId" column="in_id"/>
        <result property="vtId" column="in_vt_id"/>
        <result property="inIntegralNum" column="in_integral_num"/>
        <result property="inAccessStatus" column="in_access_status"/>
        <association property="volunteer" resultMap="com.biaogan.system.mapper.VolIntegralMapper.VolunteerMap"/>
    </resultMap>
   
    <select id="selectVolIntegralListOverride" parameterType="com.biaogan.system.domain.VolIntegral" resultMap="VolIntegralMap">
       select vt.vt_id as vtidcp ,vt.vt_name,vol.* from vol_integral  vol
            left join volunteer vt on vol.in_vt_id= vt.vt_id
        <where>
            <if test="vtId != null ">and in_vt_id = #{vtId}</if>
            <if test="vtName != null ">and vt.vt_name = #{vtName}</if>         ---此处的vtName是 volunteer表中的
            <if test="inIntegralNum != null ">and in_integral_num = #{inIntegralNum}</if>
            <if test="inAccessStatus != null ">and in_access_status = #{inAccessStatus}</if>
            <if test="createId != null ">and create_id = #{createId}</if>
            <if test="createUser != null  and createUser != ''">and create_user = #{createUser}</if>
            <if test="updateUser != null  and updateUser != ''">and update_user = #{updateUser}</if>
            <if test="updateId != null ">and update_id = #{updateId}</if>
        </where>
        ORDER BY create_time  Desc ,update_time Desc
    </select>

 

 02、原理讲解

 

标签:name,vol,单向,private,vt,mybatis,id,association,volunteer
来源: https://www.cnblogs.com/zhangzaizz/p/16643206.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有