Grails GORM:如何在嵌入式域上进行反射?

Grails GORM:如何在嵌入式域上进行反射?,grails,gorm,Grails,Gorm,我想对域关联进行反射,为RESTful WS-scaffolding自动生成JSON/XML格式的类描述符文件 示例域包括: class Roof { Chimney chimney = new Chimney() static embedded = ['chimney'] } class Chimney { float height } 我使用此代码了解GORM类类型: GrailsDomainClassPersistentEntity entity = Roof

我想对域关联进行反射,为RESTful WS-scaffolding自动生成JSON/XML格式的类描述符文件

示例域包括:

class Roof {
    Chimney chimney = new Chimney() 
    static embedded = ['chimney']
}

class Chimney {
    float height
}
我使用此代码了解GORM类类型:

GrailsDomainClassPersistentEntity entity = Roof.gormPersistentEntity

entity?.persistentProperties.each { PersistentProperty property ->
    Class<?> cl = property.getType()
}
检查域类的嵌入字段的值,并扫描类属性的名称以查找匹配项

Embedded e = property
e.getAssociatedEntity() //null