在 Grails 中,如何使用纯 SQL/DDL 以与使用 GORM/ORM 相同的方式创建/删除表?
例如,当使用 GORM/ORM 时,用于持久性的表会在集成测试运行时和应用程序执行期间定期创建/删除和插入。
我知道有一种方法可以只使用 Groovy,如名为“高级用法”here 的示例所示。 ,但我正在寻找更多类似于已经内置到框架中的东西,我可以在其中指定要加载 DDL 的 SQL 文件。
最佳答案
I'm looking for something more along the lines of being built into the framework already, something where I can specify an SQL file with DDL to be loaded.
Bootstrap.groovy
, 依赖注入(inject) DataSource Spring bean init
关闭Bootstrap.groovy
使用 DataSource 连接到 DB destroy
关闭Bootstrap.groovy
, 删除数据库 https://stackoverflow.com/questions/9639417/