我有編碼的用戶側的用戶域和角色域和工作joinTable作爲Grails的joinTable查詢問題
static hasMany = [ roles: Role ]
...
static mapping = {
table 'user_data'
id column: 'employee_number', name: 'employeeNumber', generator: 'assigned', type: 'int'
version false
sort 'lastName'
roles joinTable: [ name: 'user_role' ]
}
我想查詢數據庫,把所有用戶提供一個安全員角色與
def roleInstance = Role.find { name == 'security_officer' }
def secList = User.findAll("from User as u where u.roles = :roleInstance", [roleInstance:roleInstance])
但我得到的錯誤
Class: com.microsoft.sqlserver.jdbc.SQLServerException
Message: The value is not set for the parameter number 1.
我在做什麼錯?
接受您的答案爲正確答案,以解除此問題爲未答覆:-) – Neoryder
此處存在同樣的問題。您的解決方案奏效:) –