Thursday, December 23, 2010

Hibernate: HQL Select query on map elements

A quick tip -
How to write HQL select query on map elements:
HBM File:

<class name="TimerData" table="timer_data" lazy="false">
    <id name="userId" type="string"/>
...........
       <map name="lastExecTimeMap" lazy="false">
              <key column="userId"/>
              <map-key column="handleType" type="string"/>
              <element column="lastExecTime" type="timestamp"/>
              <!-- <element column="handle" length="1024000"/>-->
        </map>
...........
</class>


I want to get value of lastExecTime for given value of userId and handleType.
Here's the HQL query:
"select letMap
from TimerData d inner join d.lastExecTimeMap as letMap
where d.userId = ? and index(letMap)=?"

This will return lastExecTime of type Timestamp... value of 'lastExecTimeMap' for given key 'handleType'

6 comments:

  1. Nice tips. Very innovative... Your post shows all your effort and great experience towards your work Your Information is Great if mastered very well.
    python Online training in chennai
    python training institute in marathahalli
    python training institute in btm
    Python training course in Chennai

    ReplyDelete
  2. Nice Post! Thank you for sharing very good post, it was so Nice to read and useful to improve my knowledge as updated one, keep blogging.
    It’s great to come across a blog every once in a while that isn’t
    aws training in chennai | aws training in annanagar | aws training in omr | aws training in porur | aws training in tambaram | aws training in velachery

    ReplyDelete
  3. I hope you keep blogging and sharing your design idea. It's a great skill to make even the person who doesn't know about the subject could able to understand the subject. Nice post. It is really interesting.

    Aws Training in Chennai

    Aws Training in Velachery

    Aws Training in Tambaram

    Aws Training in Porur

    Aws Training in Omr

    Aws Training in Annanagar

    ReplyDelete