我正在使用 cucumber 来测试我的 grails 应用程序。我的测试环境使用 h2 数据库。为了创建我的测试数据,我使用了我在前面部分中加载的夹具
fixtureLoader.load("fixtures")
在后面的部分中,我删除了我的数据库
def configuration = grailsApplication.mainContext.getBean("&sessionFactory").configuration
def connection = grailsApplication.mainContext.getBean('dataSource').connection
new SchemaExport( configuration, connection ).create( false, true )
测试运行得很好,直到我的会话关闭,因为有 65535 个打开的事务。
org.h2.jdbc.JdbcSQLException: Allgemeiner Fehler: "java.lang.IllegalStateException: There are 65535 open transactions [1.4.186/102]"
General error: "java.lang.IllegalStateException: There are 65535 open transactions [1.4.186/102]" [50000-186]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:168)
at org.h2.message.DbException.convert(DbException.java:295)
at org.h2.message.DbException.toSQLException(DbException.java:268)
at org.h2.message.TraceObject.logAndConvert(TraceObject.java:352)
at org.h2.jdbc.JdbcConnection.commit(JdbcConnection.java:473)
at org.h2.jdbc.JdbcConnection.setAutoCommit(JdbcConnection.java:430)
at org.grails.datastore.gorm.GormStaticApi.withTransaction(GormStaticApi.groovy:814)
at org.grails.datastore.gorm.GormStaticApi.withTransaction(GormStaticApi.groovy:714)
每次测试运行后有什么方法可以清理所有打开的事务吗?