• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Converting existing sql query to hibernate native sql query???

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Your buns are mine! But you can have this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic