告诉GORM不要坚持财产 [英] Telling GORM not to persist a property

查看:123
本文介绍了告诉GORM不要坚持财产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法告诉GORM不要坚持财产?我打算在我的User类中定义一个用于验证的确认密码属性,但不应该保留。

解决方案

使用临时关键字GORM可以指示不保留特定的属性。



以下代码片段显示使用瞬态合成器

  class Book {
static transients = [digitalCopy]

static constraints = {
releaseDate(nullable :true)
}

字符串作者
字符串标题
发布日期日期
文件digitalCopy
}

暂时声明中包含的digitalCopy属性通知GORM不要持久digitalCopy

Is there a way of telling GORM not to persist 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

这篇关于告诉GORM不要坚持财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆