We've got the tests passing now. It was actually a problem with our transaction handling leaking into non-transactional tests. Our transaction support extended Spring's TransactionAspectSupport
, and with Hibernate 3 this used to work in non-transactional tests by doing nothing. In Hibernate 4 it now fails in a roundabout way, when it tries to create a transaction with a shut-down session factory.
We modified the way tests were set up so that it wouldn't try doing any transactional stuff at all unless we were in a transactional test, and they now pass happily.
Moral: One of the perils of using a singleton is that it can easily leak stuff across tests.