I have a HQL question (in Groovy / Grails) I was hoping someone could help me.
I have a simple Asset object with a collection of one-to-many tags.
class Asset {
Set tags
static hasMany = [tags:Tag]
}
class Tag {
String name
}
What I'm trying to do in HQL:
The user passes some tags to params.tags(ex: groovy grails rocks) and wants to return Asset (s) that have these tags, and only those exact tags.
Here is my HQL that returns Assets if one or more tags are present in Assets tags:
SELECT DISTINCT a
FROM
Asset a
LEFT JOIN
a.tags t
WHERE
t.name IN (:tags)
assetList = Asset.executeQuery( hql, [tags:tokenizedTagListFromParams]
The above code works fine, but its really like OR. If any of the tags is found, it will return this Asset.
I want to return only those assets that have the same tags (including as well).
, , new Tag(name:xxx).save(), .
Tag.findByName(t1) , () HQL , .
/.