File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -485,18 +485,19 @@ ps.setInt(1,id);]]></source>
485
485
<subsection name =" sql" >
486
486
<p >
487
487
This element can be used to define a reusable fragment of SQL code that can be
488
- included in other statements. For example:
488
+ included in other statements. It can be statically (during load phase) parametrized and also included many time
489
+ with different property values. For example:
489
490
</p >
490
491
491
- <source ><![CDATA[ <sql id="userColumns"> id,username,password </sql>]]> </source >
492
+ <source ><![CDATA[ <sql id="userColumns"> ${alias}. id,${alias}. username,${alias}. password </sql>]]> </source >
492
493
493
494
<p >
494
495
The SQL fragment can then be included in another statement, for example:
495
496
</p >
496
497
497
498
<source ><![CDATA[ <select id="selectUsers" resultType="map">
498
- select <include refid="userColumns"/ >
499
- from some_table
499
+ select <include refid="userColumns"><property name="alias" value="t"/></include >
500
+ from some_table t
500
501
where id = #{id}
501
502
</select>]]> </source >
502
503
</subsection >
You can’t perform that action at this time.
0 commit comments