Say I have:
Code:
<hibernate-mapping>
<class name="Foo" table="foo">
<id name="id" type="long">
<generator class="native"/>
</id>
<map name="attribs" table="foo_attribs" cascade="all-delete-orphan">
<key column="fooId"/>
<map-key type="java.lang.String" column="name"/>
<element type="java.lang.String" column="value"/>
</map>
</hibernate-mapping>
How can I construct a Criteria query to retrieve Foo's that have an attribute with the attribute "name" of "xxxxx"....
Criterias on most other associations is simple e.g.
http://www.hibernate.org/hib_docs/api/n ... teria.html. However I want something like:
Code:
Criteria c = s.createCriteria(Foo.class)
.createCriteria("attribs")
.add(Restrictions.contains("somekey", "somevalue"));
// Or just match on key
Criteria c = s.createCriteria(Foo.class)
.createCriteria("attribs")
.add(Restrictions.containsKey("somekey"));
I don't see it....
Code:
Restrictions.isEmpty()
hints at Criteria support for collections, but I can't find what I'm looking for.
Thanks,
Andy
P.S. I know how to do it with HQL, or straight SQL, I'm mainly interested in Criteria queries.[/code]