title: How do I reset my database state after each unit test without making the whole test a transaction?
body: <p>I'm using Spring 3.1.1.RELEASE, Hibernate 4.1.0.Final, JPA 2, JUnit 4.8.1, and HSQL 2.2.7.  I want to run some JUnit tests on my service methods, and after each test, I would like any data written to the in-memory database to be rolled back.  However, I do NOT want the entire test to be treated as a transaction.  For example in this test</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration({ "classpath:test-context.xml" })
  public class ContractServiceTest 
  {
      …
  
      @Autowired
      private ContractService m_contractService;
  
      @Test
      public void testUpdateContract()
      {
          // Add the contract
          m_contractService.save(m_contract);
          Assert.assertNotNull(m_contract.getId());
          // Update the activation date by 6 months.
          final Calendar activationDate = Calendar.getInstance();
          activationDate.setTime(activationDate.getTime());
          activationDate.add(Calendar.MONTH, 6);
          m_contract.setActivationDate(activationDate.getTime());
          m_contractService.save(m_contract);
          final List&lt;Contract&gt; foundContracts = m_contractService.findContractByOppId(m_contract.getOpportunityId());
          Assert.assertEquals(foundContracts.get(0), m_contract);
      }   // testUpdateContract
  </code></pre>
  
  <p>there are three calls to the service, ("m_contractService.save", "m_contractService.save", and "m_contractService.findContractByOppId") and each is treated as a transaction, which I want.  But I don't know how to reset my in-memory database to its original state after each unit test.</p>
  
  <p>Let me know if I need to provide additional information.  </p>