考虑下面的域模型:的Grails GORM的findAll返回null收集
class Sales{
String salesInvoice
Customer customer
}
class Customer{
int customerNumber
String name
}
的问题:我试图找回给客户的所有销售。因此代码:
def sales = Sales.findAllByCustomer(Customer.get(params.id))
我没有得到客户的问题。但是当我使用println sales.dump()
我得到类似
<[email protected] elementData=[mypackage.Sales : null, mypackage.Sales : null] size=2 modCount=3>
如果我理解正确的话,这意味着查询是能够得到的Sales
清单,但我不太明白的是为什么它返回一个列表空?我尝试过急切的提取,但我不认为这会在这个特定问题中起作用。那么如何获取非空对象的列表?
您正在使用哪个版本的Grails?也许你正在运行2.0.2中更改的数据绑定处理? – stefanglase 2012-04-09 12:33:37
我仍然使用2.0.0。新的数据绑定更改如何影响我的代码?我是否必须使用其他语法或在某处添加其他配置? – 2012-04-09 12:56:06
看看下面的博文描述的变化。 http://blog.springsource.org/2012/03/28/secure-data-binding-with-grails/这个特性在2.0.2中是默认的,但是在2.0.3中是非默认的,因为它是一个突破性的变化为许多生产代码。 – stefanglase 2012-04-12 15:01:52