このリンクをたどって、アプリのパフォーマンスにプラスの変化をもたらします。
私は次の2つのクラスを持っています
class Topic {
String title
String body
String type
User user
static mapping = {
body type:"text"
}
}
と
class Follower {
Topic topic
User user
static constraints = {
}
}
上記の 2 つのクラスを念頭に置いて、次のクエリに対して同等の基準を作成することは可能ですか?
SELECT title,follower.user_ID,topic.id FROM TOPIC
left outer join follower on topic.id = follower.topic_id
where follower.user_id = 1 or follower.user_id is null;
の参照がないため失敗する次の基準を思いつきました。そのような基準の指定がないため、この基準を右結合にスイングする方法を見つけることができませんでしfollower
たtopic
def recentQuestions = Topic.createCriteria().list([sort:'lastUpdated',order:'desc',max:5]){
createAlias "follower", "f" , CriteriaSpecification.LEFT_JOIN
or{
eq('f.user',u)
isNull('f.user')
}
eq('type','FORUM',[ignoreCase: true])
}