本篇文章给大家分享的是有关mybatis使用经验是怎样的,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
List<ProductInfo> queryByPage(@Param("model") ProductQueryReq queryModel);
<select id="queryByPage" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from product_info where is_deleted='N' <if test= "model.productStatus != null"> and status = #{model.productStatus,jdbcType=INTEGER} </if> </select>
mapper.xml中不写则启动报错:
BoundSql.getParameterObject():
List<ProductInfo> queryByPage(ProductQueryReq queryModel);
如果mapper.xml用了别名报错:
UserImageTransfer selectFirstHistoryOrcInfo(String productCode, String userId);
collection 下 主表 和附表 都需要查出主键;即使<id>标签写了其他字段也没用,一定是数据库表真实的主键.
<resultMap id="BaseResultMap" type="com.noob.domain.CmbClaimPackage" > <id column="id" property="id" jdbcType="BIGINT" /> <result column="batch_no" property="batchNo" jdbcType="VARCHAR" /> <result column="product_code" property="productCode" jdbcType="VARCHAR" /> <result column="package_no" property="packageNo" jdbcType="VARCHAR" /> <result column="serial_no" property="serialNo" jdbcType="VARCHAR" /> <result column="amount" property="amount" jdbcType="DECIMAL" /> <result column="total_count" property="totalCount" jdbcType="DECIMAL" /> <result column="origin_info" property="originInfo" jdbcType="VARCHAR" /> <result column="trade_status" property="tradeStatus" jdbcType="INTEGER" /> <result column="return_info" property="returnInfo" jdbcType="VARCHAR" /> <result column="upload_sign" property="uploadSign" jdbcType="CHAR" /> <result column="last_upload_date" property="lastUploadDate" jdbcType="VARCHAR" /> <result column="remark" property="remark" jdbcType="VARCHAR" /> <result column="creator" property="creator" jdbcType="VARCHAR" /> <result column="gmt_created" property="gmtCreated" jdbcType="TIMESTAMP" /> <result column="modifier" property="modifier" jdbcType="VARCHAR" /> <result column="gmt_modified" property="gmtModified" jdbcType="TIMESTAMP" /> <result column="is_deleted" property="isDeleted" jdbcType="CHAR" /> </resultMap> <resultMap id="PackageModelResultMap" type="com.noob.model.CmbClaimPackageModel" extends="BaseResultMap"> <collection property="detailList" javaType="list" ofType="com.noob.domain.CmbClaimDetail"> <id column="d_id" property="id" jdbcType="BIGINT" /> <result column="d_batch_no" property="batchNo" jdbcType="VARCHAR" /> <result column="d_product_code" property="productCode" jdbcType="VARCHAR" /> <result column="d_amount" property="amount" jdbcType="DECIMAL" /> <result column="d_package_no" property="packageNo" jdbcType="VARCHAR" /> <result column="d_contract_no" property="contractNo" jdbcType="VARCHAR" /> <result column="d_policy_no" property="policyNo" jdbcType="VARCHAR" /> <result column="d_serial_no" property="serialNo" jdbcType="VARCHAR" /> <result column="d_trade_no" property="tradeNo" jdbcType="VARCHAR" /> <result column="d_report_amount" property="reportAmt" jdbcType="DECIMAL" /> <result column="d_trade_status" property="tradeStatus" jdbcType="INTEGER" /> <result column="d_resp_code" property="respCode" jdbcType="VARCHAR" /> <result column="d_resp_msg" property="respMsg" jdbcType="VARCHAR" /> <result column="d_report_no" property="reportNo" jdbcType="VARCHAR" /> <result column="d_claim_no" property="claimNo" jdbcType="VARCHAR" /> <result column="d_return_info" property="returnInfo" jdbcType="VARCHAR" /> <result column="d_agreed_repay_date" property="agreedRepayDate" jdbcType="VARCHAR" /> <result column="d_gmt_created" property="gmtCreated" jdbcType="TIMESTAMP" /> </collection> </resultMap> <select id="selectDoing" resultMap="PackageModelResultMap" parameterType="java.util.Date" > select p.id, p.batch_no, p.serial_no, p.product_code, p.package_no, p.amount, p.origin_info, p.trade_status, p.return_info, d.id d_id, d.product_code d_product_code, d.package_no d_package_no, d.batch_no d_batch_no, d.serial_no d_serial_no, d.amount d_amount, d.contract_no d_contract_no, d.policy_no d_policy_no, d.trade_no d_trade_no, d.report_amount d_report_amount, d.trade_status d_trade_status, d.resp_code d_resp_code, d.resp_msg d_resp_msg, d.report_no d_report_no, d.claim_no d_claim_no, d.agreed_repay_date d_agreed_repay_date, d.gmt_created d_gmt_created, d.return_info d_return_info from cmb_creditcard_claim_package p inner join cmb_creditcard_claim_detail d on p.batch_no = d.batch_no where p.gmt_created >= #{beginDate,jdbcType=TIMESTAMP} and <include refid="doing_condition"/> and <include refid="alive_condition"/> </select>
以上就是mybatis使用经验是怎样的,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。