Mongodb 静态mapWith=";蒙戈;?

Mongodb 静态mapWith=";蒙戈;?,mongodb,grails,Mongodb,Grails,静态mapWith=“mongo” 我完全不清楚这意味着什么。据 mapWith 目的 mapWith静态属性增加了控制域 类正在被持久化 示例 class Airport { static mapWith = "none" } 我还讨论了这个问题:在开发模式下通过元编程删除simpledb mapWith 在我的grails应用程序中 静态mapWith=“mongo” 可能正在使用mongoDB插件。 但我还是不清楚。 我还浏览了这些stackoverflow链接: 在Grai

静态mapWith=“mongo”

我完全不清楚这意味着什么。据

mapWith

目的

mapWith静态属性增加了控制域 类正在被持久化

示例

class Airport {
  static mapWith = "none"

}
我还讨论了这个问题:在开发模式下通过元编程删除simpledb mapWith

在我的grails应用程序中

静态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';
    }
    
    可以说,使用命令对象而不是域更好,但它有自己的优势:

    可以使用GrailDomainClass访问它。 它在通过脚手架生成UI时参与

    另请参见此链接


    !

    我同意@Mananpreet Singh的回答,但要明确指出的是,静态映射with=“mongo”意味着如果您希望使用mongo而不是Hibernate持久化特定域类,则必须使用它


    链接从2021年起中断