static mapWith = "mongo"
我完全不清楚这是什么意思。根据http://grails.github.io/grails-doc/3.0.x/ref/Domain%20Classes/mapWith.html
mapWith
Purpose
The mapWith static property adds the ability to control if a domain class is being persisted.
Examples
class Airport { static mapWith = "none" }
I also went through this question Remove simpledb mapWith by meta programming in dev mode
我在我的 grails 应用程序中得到一个想法,
static mapWith = "mongo"
可能正在使用 mongoDB 插件。 但我还是不清楚。 我还浏览了这些 stackoverflow 链接:
最佳答案
在 Grails 中,如果我们想让某些字段非持久性,我们可以像这样使用 transient 关键字:
class DomainClass {
static transients = ['field1', 'field2']
Integer field1
Integer field2
Integer persistentField1
Integer persistentField2
}
也可以通过使用 mapwith 关键字使整个领域类非持久性。
class NonPersistentDomain {
.........
....................
.......................
static mapWith = 'none';
}
有人会争辩说使用命令对象而不是域更好,但它有其自身的优势:
可以使用 GrailsDomainClass 访问它。 它在通过脚手架生成 UI 时参与。
另请参阅此链接
关于mongodb - static mapWith ="mongo"实际上做了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34831087/