【问题标题】:Are Grails getDirtyPropertyNames and getPersistentValue supported by MongDB?MongoDB 是否支持 Girls getDirtyPropertyNames 和 getPersistentValue?
【发布时间】:2015-09-08 16:41:27
【问题描述】:

我正在使用 Grails 版本 2.4.2 和 MongoDB 2.6 创建了一个域类 Foo

class Foo {
  String slug
  String name
  String toString(){
    "${name}"
  }
  static constraints = {
    name blank: false
  }
  @Override
  def beforeUpdate(){
  if(isDirty("slug"){
    println "beforeUpdate() current value is  " +  this.slug
    println "original property names that were changed = " +     this.getDirtyPropertyNames()
    println "original value = " + this.getPersistentValue("slug")
  } 
 }
}

我用脚手架创建了一个 FooController

class FooController{
  static scaffold = true
}

我运行应用程序并创建一个新的 foo 输入一个 name 字段和一个 slug 字段值,然后更新 slug 字段

MongoDB 是否支持这些方法? getPersistentValue getDirtyPropertyNames

【问题讨论】:

  • >beforeUpate() 当前值为 abcde > >原始属性名称已更改 =[] > >原始值 = null
  • 控制台输出
    >beforeUpate() 当前值为 abcde
    > >原始属性名称已更改 =[]
    > >原始值 = null

标签: mongodb grails


【解决方案1】:

我现在将 Grails MongoDB 插件从 :mongodb:3.0.1 更新到最新版本 3.0.3。解决了这个问题,现在getPersistentValue()getDirtyPropertyNames() 方法都适用于 MongoDB。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-07
    • 2020-09-14
    • 1970-01-01
    • 2011-10-09
    • 2011-11-12
    • 2015-05-12
    • 1970-01-01
    • 2011-08-11
    相关资源
    最近更新 更多