Hi fsouleil, thanks for your reply. I had addressed this issue by specifying the flush-mode of the sql-query, just like following:
Code:
<sql-query name="Quotation_query" flush-mode="always">
<return-scalar column="id" type="integer"/>
<return-scalar column="name" type="string"/>
<![CDATA[
select q.quotationId as id, q.quotationName as name from quotation q where q.quotationId = :qid
]]>
</sql-query>
When I tracked the source codes, I found hibernate use quereySpaces and flush-mode to decide whether to flush before sql-query execution or not. But I could not find where to specify the querySpaces for sql-query. sql-query could be locate inside or outside the CLASS elemnt in the *.hbm.xml file. So I tried to move the sql-query inside the CLASS element, but hibernate throwed exception when executed the sql-query. It could not find the sql-query. This confused me.