heronsanches
heronsanches

Reputation: 596

Is there a way to use the mapping GORM 6 "defaultValue" when saving a domain instance

Suppose I have the following domain class:

class DomainClass{

   String field1
   ...
   static mapping = {
      field1 defaultValue: "'Field1'" 
      ...               
   }

}

Now I want to save the DomainClass instance using the "defaultValue", in the same way when using a sql insert into a postgresql (INSERT INTO domain_class VALUES(default, field2, field3, ...)), e.g.

DomainClass dc = new DomainClass()
dc.field1 = "defaultValue"
...
dc.save()

Upvotes: 0

Views: 86

Answers (1)

Jeff Scott Brown
Jeff Scott Brown

Reputation: 27200

You can do this...

class DomainClass{

    String field1 = "some default value"

    // ...
}

Upvotes: 3

Related Questions