Grails为域类获取大小为0的元素很多
以下是我的池域类:Grails为域类获取大小为0的元素很多,grails,gorm,Grails,Gorm,以下是我的池域类: class Pool { //Can be account id or name dependent on input csv format String poolName static hasMany = [accountToFollow:AccountToFollow] static constraints = { poolName nullable: false,unique: true accountTo
class Pool {
//Can be account id or name dependent on input csv format
String poolName
static hasMany = [accountToFollow:AccountToFollow]
static constraints = {
poolName nullable: false,unique: true
accountToFollow nullable: true
}
}
下面是我如何检索特定池的accountToFollow
def poolInstance = Pool.findByPoolName("First Pool")
int count = Integer.parseInt(params.numHandlesToFollow)
println "AccountToFollow: ${poolInstance.accountToFollow.size()}"
数据库中有超过5万个accountToFollow(通过在编辑“第一个池”和检查数据库时列出accountToFollow来确认)。
为什么我会得到0?def count=POOLESTANCE.accountToFollow.size()返回什么?@vahid它返回0,这可能是因为
accountToFollow
是延迟加载的?可以通过AccountToFollow
域类-AccountToFollow.findAllByPool(poolstance).size()进行搜索?