本篇文章給大家分享的是有關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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。