Grails中的domain使用嵌入式对象(值对象)

代码:

class Person { 
    String name
    Country bornInCountry
    Country livesInCountry 
    static embedded = ['bornInCountry', 'livesInCountry']
}
 // If you don't want an associated table created for this class, either
// define it in the same file as Person or put Country.groovy under the
// src/groovy directory.
class Country { 
String iso3 
String name
}

需要注意: Country 类通常放在src/groovy包中,因为这样,grails就不会自动为这个类建表了


你可能感兴趣的:(object,embedded,grails,value)