PDA

View Full Version : AbstractTransactionalSpringContextTests rollback fails?



debradley@gmail.com
Jul 22nd, 2005, 01:37 PM
I'm using AbstractTransactionalSpringContextTests in some unit tests with great success on my Windows development environment running MySQL 4.1. My database is happily always left in a clean state no matter what happens in the unit tests.

However when I deploy the same code to Redhat Enterprise 4 (from CVS), also running MySQL 4.1, the unit tests do not rollback transactions. Data created by the unit test is left in the database after the tests.

How can this be happening? Any suggestions on what might be going wrong? Thanks.

debradley@gmail.com
Jul 22nd, 2005, 01:46 PM
The answer is:

The tables were created as InnoDB tables. My Hibernate properties had the dialect set (incorrectly) to MySQL and hbm2ddl set to create-drop. As a result, Hibernate then created the tables as ISAM tables which don't support transactions.

On Windows this does not happen - having the dialect as MySQL did not cause a problem. I'm not sure why the behavior is inconsistent. Perhaps a MySQL configuration setting? A bug in Spring?

The solution, at any rate, is to set the dialect to MySQLInnoDB