Hi All,
Just amazed by the way Hibernate generates Queries. Hibernate Rocks.
Yippie. I figured it out myself. It feels really good to figure out how to use Hibernate. Everyday is a challenge when using hibernate.
The good thing about Hibernate is is that it has so much documentation but the bad thing is you should have read the whole thing to easily work with Hibernate. Suppose you want to know about Stored Procedures, just reading the Stored Procedures section is not enough. Not complaining, I am thankful atleast this form of documentation is there.
The Solution:
---------------
Use <return-scalar> to define the columns and then use the Transformer. The reason you have to define <return-scalar> is that the column names come back in CAPITAL and hibernate will complain that there is no mapping defined for that column.
Code:
<sql-query name="getAllTasks" callable="true">
<return-scalar column="taskId" type="long"/>
<return-scalar column="taskName" type="string"/>
{ ? = call FN_TEST_TASK_TASKINSTANCE(:processDefinitionId) }
</sql-query>
Code:
Query query = session.getNamedQuery("getAllTasks");
query.setParameter("processDefinitionId", new Long(processDefinitionId));
query.setResultTransformer(Transformers.aliasToBean(TaskTaskInstanceVO.class));
I wasted almost 8 to 12 hours on this one. I hope this is helpful to some newbie. Thanks a lot for MAX for introducing the ResultTransformer in Query.
I hope i will use Hibernate in the next project, so what i learnt does not go waste.
Rgds
Prashanth