开发者

Telling GORM not to persist a property

Is there a way of telling GORM not to pers开发者_运维百科ist a property? I'm planning to define a confirm password property on my User class that I'll use for validation, but shouldn't be persisted.


Using transient key word GORM can be directed not to persist specific property.

Following code snippets shows the use of transient proerties

class Book {
  static transients = [ "digitalCopy" ]

  static constraints = {
    releaseDate(nullable: true)
  }    

  String author
  String title
  Date releaseDate
  File digitalCopy
}

digitalCopy property included in transient declaration notifies GORM not to persist digitalCopy


OK - just managed to answer my own question with some more searching. Should have been more patient. A static transients property "defines a list of property names that should not be persisted to the database. This is often useful if you have read-only getters that include logic."

http://grails.org/doc/latest/ref/Domain%20Classes/transients.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜