What is the experience of using mybatis?
This article is to share with you about the experience of using mybatis, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
@ Param uses @ Param ("model") specified in the Java code, and List queryByPage (@ Param ("model") ProductQueryReq queryModel) is also required in the mapper.xml configuration; select from product_info where is_deleted='N' and status = # {model.productStatus,jdbcType=INTEGER}
If it is not written in mapper.xml, an error message will be started:
BoundSql.getParameterObject ():
There is only one parameter that can not specify @ Param, and the object property List queryByPage (ProductQueryReq queryModel) can be used directly in mapper.xml.
If mapper.xml uses an alias to report an error:
Multiple parameters of the same type also need to be defined @ Param UserImageTransfer selectFirstHistoryOrcInfo (String productCode, String userId)
The usage of collection
Under collection, both the primary table and the schedule need to find the primary key; even if the label has written other fields, it must be the real primary key of the database table.
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 and above is the experience of using mybatis The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.