我正在使用黄瓜来测试我的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)
有没有办法在每次测试运行后清理所有打开的事务?