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