Trying to figure out how to do a criteria query matching a certain key and value in a Map collection. Is this possible?
Mapping documents:
Code:
<class name="Asset" table="ASSETS">
<map name="customAttributes" table="ASSET_CUSTOM_ATTRIBUTES_VALUES">
<key column="ACAV_ASID" />
<map-key-many-to-many column="ACAV_CAID" class="AssetTypeCustomAttribute"/>
<element type="java.lang.String" column="ACAV_VALUE"/>
</map>
</class>
Code between sessionFactory.openSession() and session.close():Code:
//
AssetTypeCustomAttribute customAttribute = //...
// Is there a criteria equivalent for the following?
Query query = (Query) session.createQuery("from Asset asset where asset.customAttributes[:value]=:key");
query.setParameter("key",customAttribute);
query.setParameter("value", "some value");
List l=query.list();