title: Grails integration tests and transactions
body: <p>I don't get why this integration test fails. I can get the test to pass by either removing the <code>@Transactional(propagation = Propagation.REQUIRES_NEW)</code> annotation above the service method, OR by setting <code>transactional = false</code> in the Integration Test </p>
  
  <p>I realize that the integration test itself is running in a transaction, and that's why I've got the annotation on the service method.</p>
  
  <pre><code>class DbTests extends GrailsUnitTestCase {
  
  boolean transactional = true
  def customerService
  
  void testTransactionsCommit() {
      def orderIds = [1, 2, 3]
      orderIds.each  { // lets make sure they all start out as Active
          def order = Order.get(it)
          order.isActive = true
          order.save(flush:true, validate:true, failOnError: true)
      }
  
      customerService.cancelOrders(orderIds)
  
      orderIds.each  {
          def order = Order.get(it).refresh()
          assertEquals false, order.isActive
      }
  }
  </code></pre>
  
  <p>and my service method is defined:</p>
  
  <pre><code>class CustomerService {
  
  boolean transactional = true
  @Transactional(propagation = Propagation.REQUIRES_NEW)
  def cancelOrders(def orderIds) {
      orderIds.each {
          Order order = Order.get(it)
          if(order.id == 5) //
              throw new RuntimeException('Simulating an exception here, panic!')
          order.isActive = false
          order.save(flush:true, validate:true, failOnError: true)
          println "Order.id = $order.id is ${order.isActive? 'ACTIVE' : 'CANCELLED'}"
      }
  }}
  </code></pre>
  
  <p>The Order entity is a simple domain object and I'm on Grails 1.2.1, MySQL 5.x (dialect=org.hibernate.dialect.MySQL5InnoDBDialect)</p>
  
  <p>I've seen this related post, but still no cigar :(</p>
  
  <p><a href="https://stackoverflow.com/questions/2072648/grails-service-transactions">Grails Service Transactions</a></p>