码迷,mamicode.com
首页 > 数据库 > 详细

Mybatis <Sql>标签

时间:2016-06-11 11:43:37      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:

重复的SQL预计永远不可避免,<sql>标签就是用来解决这个问题的

<sql id="sql1">id,name,age,gender</sql>

<select id="getPerson" parameterType="int" resultType="orm.Person">
    select 
    <include refid="sql1"></include>
     from Person where id=#{id}
</select>

 

<sql>:定义重复代码

.id:sql代码块的名称

<include>:引用sql代码

refid:需要应用sql代码块的id

Mybatis <Sql>标签

标签:

原文地址:http://www.cnblogs.com/caoyc/p/5574853.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!