You can use extends attribute on statement tag as
<select id="GetAllAccounts"
resultMap="indexed-account-result">
select
Account_ID,
Account_FirstName,
Account_LastName,
Account_Email
from Accounts
</select>
<select id="GetAllAccountsOrderByName"
extends="GetAllAccounts"
resultMap="indexed-account-result">
order by Account_FirstName
</select>
<select id="GetOneAccount"
extends="GetAllAccounts"
resultMap="indexed-account-result">
where Account_ID = #value#
</select>
Cheers,
Gilles
On 10/7/05, Ron Grabowski <[EMAIL PROTECTED]> wrote:
I've added an issue for this. I don't think anyone has started on it
yet:
http://issues.apache.org/jira/browse/IBATISNET-116
--- Hai Hoang <[EMAIL PROTECTED]> wrote:
> 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
>

