zoukankan      html  css  js  c++  java
  • MyBatis中collection (一对一,一对多)

    MyBatis学习http://www.mybatis.org/mybatis-3/zh/index.html

    大对象InsuranceDetailsVO:

    com.quicksure.mobile.entity.InsuranceDetailsVO

    public
    class InsuranceDetailsVO { private String orderno; @Resource private Baseinfor baseinfor; @Resource private Coverageinfor coverageinfor; private List<Coverageinfor> coverageinfors; //险种的集合 ........其它无关实体类和get、set方法省略 }

    实体类Baseinfor:

    com.quicksure.mobile.entity.Baseinfor

    public
    class Baseinfor { private String orderno;// 订单号 ......一些基本的字段和get、set方法 }

    对应的mapper:

    联合查询,一对一
    <
    mapper namespace="com.quicksure.mobile.dao.VelicheBatchCheckMapper"> <resultMap id="queryBatchPolicy" type="com.quicksure.mobile.entity.InsuranceDetailsVO"> <id column="orderNo" jdbcType="VARCHAR" property="orderno" /> <collection property="baseinfor" ofType="com.quicksure.mobile.entity.Baseinfor" resultMap="baseinforResult"></collection> </resultMap>
    联合查询,一对多 <resultMap id="queryBatchPolicy1" type="com.quicksure.mobile.entity.InsuranceDetailsVO"> <id column="orderNo" jdbcType="VARCHAR" property="orderno" /> <collection property="baseinfor" ofType="com.quicksure.mobile.entity.Baseinfor" resultMap="baseinforResult"></collection> <collection property="coverageinfors" ofType="com.quicksure.mobile.entity.Coverageinfor" resultMap="coverageinforResult"></collection> </resultMap>
    <resultMap id="baseinforResult" type="com.quicksure.mobile.entity.Baseinfor">
      ......基本字段映射
    </resultMap>

    <resultMap id="coverageinforResult" type="com.quicksure.mobile.entity.Coverageinfor">
      ......基本字段映射
    </resultMap>

    <!-- CSR导出excel时查询对应的数据 --> <select id="CSRExportExcel" parameterType="java.util.Map" resultMap="queryBatchPolicy1"> select baseinfor.orderNo,baseinfor.syapplicationNo,baseinfor.jqapplicationNo,baseinfor.sypolicyNo,baseinfor.jqpolicyNo, baseinfor.deptAddress,vhinfor.drvOwner,vhinfor.lcnNo,baseinfor.sypolicyStartDate,baseinfor.jqpolicyStartDate, baseinfor.orderstate,baseinfor.syPremium,baseinfor.jqPremium,baseinfor.taxPremium,baseinfor.totalPremium, baseinfor.updateTime,baseinfor.paymentMethod,baseinfor.jqpolicyNo,baseinfor.sypolicyNo,baseinfor.createTime, coverage.* from ludimb_baseinfor baseinfor LEFT JOIN ludimb_vhlinfor vhinfor on baseinfor.vhlinforId = vhinfor.vhiinforId LEFT JOIN ludimb_coverageinfor coverage on baseinfor.orderNo = coverage.baseinforOrderNo where 1=1 <if test="deptcode!=null and deptcode!='' and deptcode!=1"> and baseinfor.deptNo=#{deptcode} </if> <if test="orderNo!=null and orderNo!=''"> and baseinfor.orderNo=#{orderNo} </if> <if test="drvowner!=null and drvowner!=''"> and vhinfor.drvOwner=#{drvowner} </if> <if test="lcnNo!=null and lcnNo!=''"> and vhinfor.lcnNo=#{lcnNo} </if> <choose> <when test="orderstate==1"> and baseinfor.orderstate in (30,40) </when> <when test="orderstate==2"> and baseinfor.orderstate in (50,60,70) </when> <when test="orderstate==3"> and baseinfor.orderstate in (10,20) </when> <when test="orderstate==4"> and baseinfor.orderstate = 80 </when> <otherwise> </otherwise> </choose> <if test="createStartTime!=null and createStartTime!=''"> <![CDATA[ and baseinfor.createTime >= #{createStartTime} ]]> </if> <if test="createEndTime!=null and createEndTime!=''"> <![CDATA[ and baseinfor.createTime <= #{createEndTime} ]]> </if> </select>
    <mapper>
  • 相关阅读:
    55种网页常用小技巧(javascript) (转)
    如何利用RadioButtonList实现datagrid列的单选 (转)
    实现数据分类汇总的SQL语句 (转)
    在ASP.Net中两种利用CSS实现多界面的方法. (转)
    ASP.NET 中 Session 实现原理浅析 [1] 会话的建立流程
    用户控件中使用客户端脚本的控件名称问题 (转)
    快速理解.NET Framework[翻译] (转)挺不错的翻译
    table的宽度,单元格内换行问题 (转)
    实现类似Windows资源管理器的DataGrid(转)
    vs.net web项目使用visual source safe进行源代码管理(转)
  • 原文地址:https://www.cnblogs.com/ldbangel/p/6233806.html
Copyright © 2011-2022 走看看