ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maarten Meijer <mjmei...@xs4all.nl>
Subject multiple SQL statments in one SqlMap <sql> or <select>
Date Tue, 17 Apr 2007 11:54:04 GMT
Can I do the following to make a single clean up query for after unit  
testing:

<sqlMap namespace="junit">
     <!-- then do the special SQL operations for unit testing -->
     <select id="countEmpty" resultClass="java.lang.Integer">
         SELECT count(*) FROM `lqueries` WHERE q_nresults = 0 AND
         q_ID &gt; #firstProject# AND
         q_ID &lt;= #lastProject#;
     </select>
     <select id="restoreTables" resultClass="java.lang.Integer">
         DELETE FROM `lqueries` WHERE q_ID &gt; #firstProject#;
         DELETE FROM `lresults` WHERE r_ID &gt; #firstProject#;
         ALTER TABLE `lqueries` AUTO_INCREMENT = #firstProject#;
     </select>
</sqlMap>

If I try this, I get the following error message because of an  
SQLException:

junit.framework.AssertionFailedError: restoreTables() :
--- The error occurred in com/fold1/dbtest/sqlmap/maps/UnitTests.xml.
--- The error occurred while applying a parameter map.
--- Check the junit.restoreTables-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: java.sql.SQLException: You have an error in your SQL  
syntax; check the manual that corresponds to your MySQL server  
version for the right syntax to use near ';         DELETE FROM  
`lresults` WHERE r_ID > 6672;         ALTER TABLE `lquerie' at line 1

Is there a workaround whereby I can leave/hide all my SQL clean up  
statements in the SqlMap and call them as a single unit from Java?

Maarten
Mime
View raw message