如何在 Grails 3.0.1 中设置休眠方言

How to set the hibernate dialect in Grails 3.0.1

我正在试用新的 Grails 3 堆栈,但遇到了 gorm / hibernate 问题。我有一个自定义的休眠方言来支持一些数据库功能,但是 application.yml 文件中的方言设置似乎被忽略了:

dataSource:
    dialect: "our.namespace.Dialect"
    pooled: true
    jmxExport: false
    driverClassName: "org.postgresql.Driver"        
    username: user
    password: password
    dbCreate: 'update'

our.namespace.Dialect 似乎从未被实例化,并且 gorm 在尝试创建数据库时抛出以下错误:

ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - HHH000299: Could not complete schema update
org.hibernate.MappingException: No Dialect mapping for JDBC type: 90001

类型 90001 是方言应处理的 JDBC 类型代码之一。

此代码和设置在我从事的 Grails 2.x.y 项目中运行良好。

如何在 Grails 3.0.1 中设置休眠方言?

这似乎是 Grails 3.0.1 的一个已知问题,并且有一个公开的错误报告:

https://github.com/grails/grails-core/issues/614

当前的解决方法是在 application.yml 文件的休眠部分设置方言:

hibernate:
    dialect: "our.namespace.Dialect"