Search code examples
grailsgrails-ormgrails-domain-class

GORM: What is reference:true in Grails domain class mapping block?


public class Address {
    static mapWith = "mongo"

    Region region;
    Zone zone;

    static mapping = {
        id generator: 'identity'
        region reference:true
        zone reference:true
    }
}

I'm interested in knowing what reference:true does.

In my experience, leaving it off gives exactly the same result except there's no DBRef in the actual mongo document.


Solution

  • It looks like reference controlls how documents are linked.

    When true, the related documents are referenced by db-refs, if false, GORM inserts simple id, aka Manual references in mongo