当我第一次尝试通过id获取我的班级时,它给出了包括子对象在内的整个详细对象,然后仅给出了父类的属性,这是到目前为止我正在尝试的班级和代码段,
package groovyproject import groovy.transform.ToString @ToString(includes = ['name']) class Employee{ String name String description Address address static constraints = { name unique: true description nullable: true address nullable: true } static mapping = { description type: 'text' sort "name": "asc" } }
我通过ID获取员工的代码是
Employee.findById(empId)
所以我第一次没有得到回应(这是正确的)
{“ id”:1,“ name”:“ User1”,“ description”:null,“ address”:[ { “密码”:41102, “ city”:“浦那”, “状态”:“ MH” }, { “密码”:23456, “ city”:“ Ahmedabad”, “州”:“ GJ” }]}
然后总是低于响应(不正确)
{“ id”:1,“ name”:“ User1”,“ description”:null}
我正在使用grails 2.5.1版。 提前致谢。