0
用戶我有以下幾點:查找特定春季安全角色
def userInstance=User.findAll("from User u where u.merchant is not null and u.merchant.id = ? and u.authorities.authority.contains('ROLE_MERCHANT')", merchantId)
並得到以下錯誤:
org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: (near line 1, column 121 [from com.testing.tests.User u where u.merchant is not null and u.merchant.id = ? and u.authorities.authority.contains('ROLE_MERCHANT')]
at $Proxy20.createQuery(Unknown Source)
at testing.admin.UserService.findByMerchantId(UserService.groovy:14)
我怎麼只能返回具有特定角色的用戶?
感謝
我嘗試withCriteria版本,我得到的,因爲'從USER_ROLE THIS_選擇this_.user_id爲y0_其中(role_alias1_.authority =?)'的SQLGrammarException。我認爲role_alias1_應該是this_(或者反過來),但是不知道爲什麼它會像這樣產生。任何指針? –
這對於我剛纔在幾分鐘之前遇到的問題確實有幫助,我可以按照邏輯進行操作,但是我不需要查詢關聯使用角色{...} – user615274