You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Kit Cragin <ki...@entervalent.com> on 2005/02/01 17:42:56 UTC

Some info on comments embedded in statements

I wanted to share some info with the group regarding comments embedded in
statements in the XML files. I found the following does not work:

1. SQL Server comments (e.g. "--") interleaved with SQL text. This one
should have been obvious to me in retrospect <sigh>. 

<delete id="deletesomething">
-- Delete children
delete from thattable where thisid = #value#
-- Delete parent
delete from thistable where thisid = #value#
</delete>

The reason is that new lines are removed so you end up with this SQL
command: "-- Delete children delete from thattable where thisid = @value --
Delete parent delete from thistable where thisid = @value" which is
obviously just one long comment.

2. Interleaved XML comments:

<delete id="deletesomething">
<!-- Delete children -->
delete from thattable where thisid = #value#
<!-- Delete parent -->
delete from thistable where thisid = #value#
</delete>

This doesn't work because newlines are removed and the statements are
concatenated without any whitespace in between: "delete from thattable where
thisid = @valuedelete from thistable where thisid = @value"

The first one is not an ibatis bug. The second one might be, but I am not
sure.

- Kit