0
我在grails查询时出错。 我有类用户:参数#1没有设置错误
class User {
String username
String passwordHash
static hasMany = [roles: Role, permissions: String, clients: User, owners: User]
}
当我查询:
def addClient() {
def principal = SecurityUtils.subject?.principal
User currentUser = User.findByUsername(principal);
if (request.method == 'GET') {
User user = new User()
[client: currentUser, clientCount: User.countByOwners(currentUser)]
}
}
的Grails说:
参数 “#1” 未设置; SQL语句:select count(*)as y0_ from user this_ where this_.id =? [90012-164]
为什么?
是的,你的权利,业主是一个集合的问题。我解决了问题方式:User.withCriteria {拥有者{inList(“id”,[currentUser.id])}} .size() – 2013-04-19 03:01:36