Backpedal

Backpedal is a JDBC driver that can be instructed to undo all SQL statements that were issued through it. It is intended, primarily, for use in unit testing and acceptance testing. There are plug-ins that make this possible in the JUnit and FIT testing frameworks.

Backpedal intercepts all SQL statements issued through it and, for each SQL statement, generates "backpedal SQL" that will undo that SQL statement. This backpedal SQL is added to a stack. When instructed to do so (via a simple message to a socket), backpedal will pop through the stack, executing each backpedal SQL statement in order.

Backpedal does not contain a comprehensive SQL parser. That would take just too much time to write and maintain. Rather, Backpedal makes use of the fact that many projects use some form of OR mapping software (be it EJB CMP, Hibernate, JDO, Toplink or what have you) and that each OR mapping implementation tends to produce SQL systematically, thereby making it more easily parsed. So, with this in mind, Backpedal allows you to plug in your own SQL parser, tailored for the SQL your OR mapping implementation produces. A SQL parser for Kodo JDO is provided, with an implementation for Hibernate soon to follow.

Implementing a custom parser is simple and documented here. If you are issuing ad hoc SQL statements rather than using an OR mapping implementation you could have a go an writing a parser for ad hoc SQL, if you are so inclined :-)