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'

Monday, December 13, 2010

Oak... Green.... Java

First of all, regarding name of the blog.... While not all the posts in this blog may be around java/j2ee; most of them will be. "Oak" & "Green" are x-names (!!!) of what is today known as "Java" programming language.

This is my second blog on tech-stuff but this is different from first one (teKNOWlogy.blogspot.com). The earlier one mostly talks about Biz side of technology - primarily startups, whereas this one is for stuff around development, primarily Java/J2EE stuff.