Quering and/or fetching map keys and values in HQL

03:52PM Sep 02, 2010 in category Dev by Manos

Hibernate Criteria supports relation but not collection based conditions so we had to use HQL for this.

2 <class name="Asset" table="ASSETS">
3 <id name="id" column="AS_ID">
4 <generator class="native" />
5 </id>
6 <!-- ... -->
7 <map name="customAttributes" table="ASSET_CUSTOM_ATTRIBUTES_VALUES" lazy="true" sort="natural">
8 <key column="ACAV_ASID" />
9 <map-key-many-to-many column="ACAV_CAID" class="AssetTypeCustomAttribute"/>
10 <element type="string" column="ACAV_VALUE"/>
11 </map>
12 </class>

We wanted to keep the customAttributes collection lazy but pre-fetch for certain occasions, as well as query based on map key and value  pairs. Here's an example of HQL used for searching:

   1 select asset from Asset asset 
2 left join fetch asset.customAttributes as customAttribute
3 where ((index(customAttribute) = ? and customAttribute = ?)
4 and (index(customAttribute) = ? and customAttribute = ?) )



Coach Outlet Online Build a network monitoring long-term mechanism of action to rectify the vigorous national network finally come to an end.

Posted by Coach Outlet Online on December 07, 2011 at 10:45 AM EET #

I was very pleased to find this site.I wanted to thank you for this great read!

Posted by Coach Outlet Store Online on December 08, 2011 at 09:27 AM EET #

It's good to see this information in your post

Posted by Coach Factory Outlet on December 14, 2011 at 10:41 AM EET #

N&aring;r nogen kommer til skobutik med henblik p&aring; at k&oslash;be nogle behagelige og gode sko det f&oslash;rste navn, <a href=&quot;http://www.nikefreerun3.net&quot; title=&quot;nike free&quot;>nike free</a>

Posted by nike free on December 31, 2011 at 09:06 AM EET #

La Jordanie, qui est officiellement connu comme le Royaume hach&eacute;mite de Jordanie est un pays qui est situ&eacute; dans <a href=&quot;http://www.jordanchaussure.com&quot; title=&quot;jordan chaussure&quot;>jordan chaussure</a>

Posted by jordan chaussure on December 31, 2011 at 09:09 AM EET #

Post a Comment:
  • HTML Syntax: NOT allowed