Maarten,
Why don't you run them as separate statements and run the delete script
in the teardown method of the test case?
-Richard
Maarten Meijer wrote:
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 > #firstProject# AND
q_ID <= #lastProject#;
</select>
<select id="restoreTables" resultClass="java.lang.Integer">
DELETE FROM `lqueries` WHERE q_ID > #firstProject#;
DELETE FROM `lresults` WHERE r_ID > #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