0
我試圖寫在HQL 3表連接查詢的Grails我3類:複雜的SQL查詢使用Grails,HQL
class Domains {
String name
Date ets
Account account
static hasMany = [facebooks: Facebook, twitters: Twitter]
}
...
class Facebook {
Boolean activated
String name
String token
String pageId
String expiryTime
String scope
Date ets
String username
Domains domains
static belongsTo = [Domains]
}
...
class FbPosts {
String postId
Long commentsCount
Long likesCount
Long sharesCount
Date date
Date ets
String message
String type
Integer postImpression
Facebook facebook
static belongsTo = [Facebook]
}
我正在嘗試獲取與域(域eid)相關的fbPosts
。我目前的HQL查詢看起來像這樣:
def fbPosts = FbPosts.findAll("from FbPosts as fb join Facebook as f on f.eid=fb.facebook_eid join Domains as d on d.eid=f.domain_eid where d.eid=?"[domain_eid])
def map = [fbPosts:fbPosts]
並且似乎不工作。請幫忙。
沒有它似乎沒有工作.. – JJDev
什麼是不工作?任何錯誤信息? –
@JJDev另外,來自'Domain'的'eid'在哪裏?我無法在域對象中看到它... –