问题在于使用默认的JSON转换器。这是您的选择:
1. Default - all fields, shallow associations a. render blah as JSON 2. Global deep converter - change all JSON converters to use deep association traversal a. grails.converters.json.default.deep = true 3. Named config marshaller using provided or custom converters a. JSON.createNamedConfig('deep'){ it.registerObjectMarshaller( new DeepDomainClassMarshaller(...) ) } b. JSON.use('deep'){ render blah as JSON } 4. Custom Class specific closure marshaller a. JSON.registerObjectMarshaller(MyClass){ return map of properties} b. render myClassInstance as JSON 5. Custom controller based closure to generate a map of properties a. convert(object){ return map of properties } b. render convert(blah) as JSON您当前正在使用选项1,这是默认选项。
您可以执行的最简单的操作是使用选项2设置全局深度转换器,但是请注意,这会影响应用程序中的所有域类。这意味着,如果您有一个大型关联树结结为一个顶级对象,并且尝试转换这些顶级对象的列表,则深层转换器将执行所有查询以获取所有关联对象及其关联对象。转。-
您可以一次加载整个数据库 :)注意。



