ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hai Hoang <haibho...@yahoo.com>
Subject Reuse SQL Fragment
Date Fri, 07 Oct 2005 21:10:36 GMT
Does IBATIS.NET supports reuse SQL-fragment such as
this
http://opensource2.atlassian.com/confluence/oss/pages/viewpage.action?pageId=707

This is useful for situation where I have the multiple
select statements in one mapping file.  For example, I
have something like this

<select id="GetApplication"
resultMap="ApplicationResult" parameterClass="int">
    SELECT 
        Application_Id, 
        Application_Name, 
        Application_Description 
    FROM 
        tb_Application 
    WHERE 
        Application_Id = #value#
</select>
<select id="GetApplicationByName"
resultMap="ApplicationResult" parameterClass="string">
    SELECT 
        Application_Id, 
        Application_Name, 
        Application_Description 
    FROM 
        tb_Application 
    WHERE 
        Application_Name = #value#
</select>

and I would like it to be like this
<sql id="selectApplication_fragment">
    SELECT 
        Application_Id, 
        Application_Name, 
        Application_Description 
    FROM 
        tb_Application 
</sql>
<select id="GetApplication"
resultMap="ApplicationResult" parameterClass="int">
    <include refid="selectApplication_fragment"/>
    WHERE 
        Application_Id = #value#
</select>
<select id="GetApplicationByName"
resultMap="ApplicationResult" parameterClass="string">
    <include refid="selectApplication_fragment"/>
    WHERE 
        Application_Name = #value#
</select>


Can you show me if there is a better way.

Thanks,
Hai



		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

Mime
View raw message