mybatis的include标签的使用
程序员文章站
2024-03-20 20:43:28
...
mybatis的include标签的使用
使用示例
- 定义代码片段
<sql id="Base_Column_List">
order_no, user_id, insurance_id, pharmacy_id, apply_product_id, insured, insured_phone,
insured_id_number, insured_province, insured_city, insured_weight, waybill_no, confirmed_date,
hospital, check_time, check_user, check_desc, policy_no, policy_time, policy_status,
edor_app_no, policy_url, insured_effect_time, insured_effica_time, policy_desc, amount,
pay_time, pay_type, tran_no, use_status, `status`, remark1, remark2, submit_time,
create_user, create_time, update_user, update_time
</sql>
- 引用代码片段
<select id="count" resultType="java.lang.Integer">
SELECT COUNT(1) FROM ep_core_insurance_group
WHERE 1=1
....
</select>
- 嵌套
<sql id="vals">(1,2,3,4)</sql>
<sql id="where1">STATUS IN <include refid="vals"/></sql>
SELECT * FROM TEST WHERE <include refid="where1"/></sql>
引用另一个xml文件的片段
A.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.test.BaseDAO">
<sql id="where">STATUS IN (1,2,3,4)</sql>
</mapper>
B.xml
SELECT * FROM TEST WHERE <include refid="com.test.BaseDAO.where"/></sql>
上一篇: mysql主从备份
下一篇: autohotkey 双击