我有一个非常简单的域对象:
class CustomEventsTester {
String value
}
和简单的测试方法
class GormEventsTest extends GroovyTestCase {
static transactional = true
void testDelete() {
def tester = new CustomEventsTester()
assert !tester.save(flush: true)
tester.value = 'abc'
assert tester.save(flush: true)
tester.value = 'lets_change'
assert tester.save(flush: true)
tester.delete(flush: true)
}
}
此测试在tester.delete
行传递异常:
| org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
at GormEventsTest.testDelete(GormEventsTest.groovy:13)
为什么?!