Criteria and collections
I have in my domain class a set of Integers like...
class MyDomain {
(...)
Set ids
(...)
}
And would like to have a criteria to find if my object has an specifid id in that set.
Which means something like...
MyDomain.withCriteria {
/* ids contains myId * /
}
'in' doesn't work - I want the reverse. myId must be within ids.
So - anyone can help me with that?
edit:
Let's suppose I have a MyDomain object with an ids set containing [2,3] and another having [3,4].
I want to have a criteria that returns all MyDomain objects that contains the id 2 in the ids set, so the result value of my criteria would be a list containing only the first MyDomain object mentioned.
按照链接@Sergio张贴如果你想/需要的标准,但我更喜欢HQL:
MyDomain.executeQuery("Select m from MyDomain m join m.ids as id where id = :id", [id: myId])
链接地址: http://www.djcxy.com/p/37108.html
上一篇: 存在子句的hibernate标准
下一篇: 标准和集合