Article {
String categoryName
static hasMany = [
tags: Tag
]
}
Tag {
String name
}
Now I want to find the list of all related articles. Related meaning, all articles that have the same category name as myArticle or any of the same tags as myArtcle.
With only matching categoryName, here is how I would get the relatedArticles using closures.
def relatedArticles = Article.list().find {it.categoryName == myArticle.categoryName }
Anyone wants to give a shot to find all articles by CategoryName or Tag Name (in a groovy way)?
Any solutions using Criteria or custom queries is appreciated too.