-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Please suggest a way to implement nested query in hibernate
PostPosted: Tue Nov 25, 2008 10:41 pm 
Newbie

Joined: Tue Nov 25, 2008 10:23 pm
Posts: 2
Hello everyone!
I am farely new to Hibernate and just have read and implemented a couple of examples from the books I have read.
However I am not being able to find a way to convert the following nested
sql (which I am using for a jdbc resultset) into an equivalent in hibernate . Could you please suggest a way (or reading) to get this done! I am looking for a class structure+hibernate mapping and the ultimate query that will retrieve the same set of results in effect from the database.

Thanks in advance, By the way I am using Hibernate 3 with Tomcat 6

Table structure is somewhat like the following


PUB_CODE STATUS_FLAG USER_ID ENTRY_DATE PUB_DATE

ENY RE jhuma 06/11/2008 06/11/2008
DCH RE jhuma 06/11/2008 06/11/2008
ENY AU jhuma 06/11/2008 08/10/2008


NESTED query for jdbc resultset


select pub_code,entry_date received,
(select entry_date from mis_outtrack where pub_code=mo.pub_code and status_flag='AU' and pub_date=mo.pub_date) audited,
(select entry_date from mis_outtrack where pub_code=mo.pub_code and status_flag='SE' and pub_date=mo.pub_date) sent,
pub_date
from mis_outtrack mo
where status_flag='RE' and PUB_DATE between '10-jan-2008' and '15-dec-2008' order by PUB_DATE


Expected Data format is ::->


PUB_CODE RECEIVED AUDITED SENT PUB_DATE

DTK 10/11/2008 10/11/2008 10/11/2008 14/09/2008
DTK 10/11/2008 10/11/2008 10/11/2008 15/09/2008
DTK 10/11/2008 10/11/2008 10/11/2008 16/09/2008
MKT 10/11/2008 10/11/2008 10/11/2008 07/10/2008
DTK 10/11/2008 10/11/2008 10/11/2008 08/10/2008
MKT 10/11/2008 10/11/2008 10/11/2008 23/10/2008


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.