iBatis SQLMaps statements with comments

Posted by Mike Haller on Friday, February 9. 2007 at 00:00
Don't use comments in SQL statements when mapping with iBatis SqlMaps.

The whole statement (even if you've got multiple sql statments within one element) gets merged into a single line. The first comment will also comment-out all further statements.

For example


<sqlmap>
 <!-- For Unit Testing -->
 <statement id="createTable">
 CREATE TABLE (...);
 -- Sample data
 INSERT INTO VALUES (...);
 </statement>
</sqlmap>
 


will result into the following SQL statement on the JDBC level:


CREATE TABLE (...); -- Sample data INSERT INTO VALUES (...);
 


and no data will be inserted into your table.



Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications
 
Submitted comments will be subject to moderation before being displayed.
 

About

My name is Mike Haller and I'm a software developer and architect at Bosch Software Innovations in Germany. I love programming, playing games and reading books. I like good food, making photos and learning and mentoring about the craftsmanship of commercial software development. Stack Overflow profile for mhaller

Quicksearch