Search code examples
mongodbgrails

Are Grails getDirtyPropertyNames and getPersistentValue supported by MongDB?


I am using Grails version 2.4.2 and MongoDB 2.6 Created a Domain class 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")
  } 
 }
}

I created a FooController with scaffolding

class FooController{
  static scaffold = true
}

I run the app and create a new foo enter a name field and a slug field value then update the slug field

Are these methods supported by MongoDB? getPersistentValue getDirtyPropertyNames


Solution

  • I updated the Grails MongoDB plugin from :mongodb:3.0.1 to the latest version which is 3.0.3 right now. That fixed it, now getPersistentValue() and getDirtyPropertyNames() methods both work with MongoDB.