posted 14 years ago
Hi,
I am currently trying to convert one of our existing module to hibernate (For POC).
In this process, i require all our existing sql queries to be converted to hibernate based queries.
Could any one please help me (as im new to hibernate) by giving example to convert the following existing sql query to hibernate native query?
(Please note that: i have already created separate DAO layer and created session object as well).
Example query(query includes subquery as well):
SELECT EL5, ELMADDRTAG, VALUEDOC, VALUEDOC_DP, CHECKEDSTATUS, SEQNO,
(SELECT COUNT(1) FROM [820LDEV1].CSD_CHEQUE_TRANS WHERE CSD_CHEQUE_TRANS.SEQNO = CSD_CHEQUE_HEADER.SEQNO)
FROM [820LDEV1].CSD_CHEQUE_HEADER
WHERE CSD_CHEQUE_HEADER.CMPCODE = ? AND CSD_CHEQUE_HEADER.PRINTSTATUS = 0 AND CSD_CHEQUE_HEADER.EL5 <> ''
Where
820LDEV1 -> schema name.
EL5, ELMADDRTAG, VALUEDOC, VALUEDOC_DP, CHECKEDSTATUS, SEQNO -> column names.
CSD_CHEQUE_HEADER,CSD_CHEQUE_TRANS -> are tables.
How can i represent this schema name in hibernate query?
session.? (which method of session is most preferable here).
Any related help is most helpful for me.
Thanks in advance for your kind help.