【问题标题】:Grails 3.0.1 - how and where to configure grails.gorm.default.mappingGrails 3.0.1 - 如何以及在何处配置 grails.gorm.default.mapping
【发布时间】:2015-06-13 11:55:59
【问题描述】:

我在旧的 Config.groovy 中:

grails.gorm.default.mapping = {
    id generator = 'identity'

    // send only the dirty fields to the database for updating
    dynamicUpdate = true
    dynamicInsert = true
}

所以我把它放在另外的 application.groovy 中,但它不会再被尊重了。所有更新都已满,将所有字段发送到数据库,即使是未更改的字段。

我试图在 application.yml 中翻译这个:

grails:
    gorm:
        default:
            mapping:
                id generator:  "identity"
                dynamicUpdate: true
                dynamicInsert: true

...但仍然没有运气。

【问题讨论】:

  • 我在源代码中发现了一个 Settings.groovy,它仍然包含 grails.gorm.default.constraints 但 grails.gorm.default.mapping 不再,所以看起来这将不再在全球范围内进行评估。用application.yml,spring或者hibernate可能还有功夫,但是我还没找到。
  • 尝试添加application.groovy 并在此处指定
  • 你说得对:不需要功夫,就这么简单。谢谢格雷姆,它有效:)
  • @GraemeRocher 嗨,当我在 application.groovy 中指定整个 Config.groovy 文件时,它显示Could not resolve all dependencies for configuration ':profile'. Type 'gradle dependencies' for more information 错误。在运行gradle dependency 时,没有一个失败。但是当我在 application.yml 中指定时,它工作正常!有没有办法只在 application.groovy 或任何配置中指定默认加载 application.groovy
  • 有没有办法在只使用 Spring Boot 时设置默认约束,而不是在 Grails 中?

标签: grails grails-orm grails-3.0


【解决方案1】:

使用 Grails 3.1.10,它可以在 application.groovy 中运行:

dataSource {
  //....
}

grails.gorm.default.mapping = {
    uuid index:'idx_uuid', type: org.hibernate.type.UUIDCharType, length: 36, defaultValue: null
    batchSize 15000
}

但将其放入 application.yml 时也没有成功

【讨论】:

  • 在 application.groovy 中使用基于闭包的配置时,Jackson 序列化程序在 /env 激活器端点中失败。
  • 我没有发现任何问题,但据我所知我没有使用这个激活器。好像已经被举报了:github.com/spring-projects/spring-boot/issues/7242
猜你喜欢
  • 2015-06-13
  • 2015-06-16
  • 2015-07-26
  • 2015-06-17
  • 1970-01-01
  • 1970-01-01
  • 2013-01-31
  • 2011-09-04
  • 1970-01-01
相关资源
最近更新 更多