-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate query not returning records
PostPosted: Thu Apr 19, 2007 1:11 am 
Newbie

Joined: Thu Apr 19, 2007 12:34 am
Posts: 8
Hi

i need to pick up some flights (airlines) which has taken off between 11th aprill 2007 12 oclock noon and 12th april 2007 12oclock noon.i have written a hivernate query whcih is not returning any records,when i am taking up the same query generated from hibernate and run it on toad it is returning record against perticular flight no.
the where clause of hibernate generated query is

where (opsfltleg0_.ORIG_ARPT_CD=schedfltle1_.ORIG_ARPT_CD )
AND(opsfltleg0_.DEST_ARPT_CD=schedfltle1_.DEST_ARPT_CD )
AND(schedfltle1_.GMT_DEP_DTM>=to_date(? , 'yyyy-mm-dd HH24:MI:SS '))
AND(schedfltle1_.GMT_DEP_DTM<=to_date(? , 'yyyy-mm-dd HH24:MI:SS '))
AND(bitand(opsfltleg0_.FLT_STAT , 16)=16 )
AND(opsfltleg0_.ORIG_ARPT_CD=stndst2_.STN_CD )
AND(opsfltleg0_.FLT_LCL_ORIG_DT between stndst2_.DST_EFF_DTM and stndst2_.DST_EXPR_DTM )
AND(opsfltleg0_.FLT_NBR>=? )
AND(opsfltleg0_.FLT_NBR<=? )
AND(opsfltleg0_.CARR_IATA_CD!='ZK' )

i have set the date as

GregorianCalendar start = new GregorianCalendar();
start.set(Calendar.MONTH, Calendar.APRIL);
start.set(Calendar.YEAR, 2007);
start.set(Calendar.DATE, 11);
start.set(Calendar.HOUR, 0);
start.set(Calendar.MINUTE, 0);
start.set(Calendar.SECOND, 0);



GregorianCalendar end = new GregorianCalendar();
end.set(Calendar.MONTH, Calendar.APRIL);
end.set(Calendar.YEAR, 2007);
end.set(Calendar.DATE, 12);
end.set(Calendar.HOUR, 0);
end.set(Calendar.MINUTE, 0);
end.set(Calendar.SECOND, 0);

when i run the query with above where clause it returning record records.But with the same parameter it is not returning any record in hibernate.

can anyone help

thanks in advance

Sas


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 19, 2007 9:40 am 
Beginner
Beginner

Joined: Thu Apr 12, 2007 10:43 am
Posts: 21
Location: Brazil
Hi saswata,
Don't forget to call GregorianCalendar.set(Calendar.MILLISECOND, 0) when you set up your Calendar's. Also, I see you're passing your dates to the query as String's. Why don't you extract Date's from the Calendar's and use them as parameters? By doing so, you can completely skip the unnecessary TO_DATE() conversion. Cheers,
Roger


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 19, 2007 9:49 am 
Newbie

Joined: Mon Jun 27, 2005 7:43 am
Posts: 13
Location: Barcelona, Spain
Also, 12oclock noon should be set like this :
Code:
GregorianCalendar.set(Calendar.HOUR_OF_DAY, 12);

If you use
Code:
GregorianCalendar.set(Calendar.HOUR, 0);

you set the time at 12oclock midnight or noon, depending on the value you may set afterwards for Calendar.AM_PM


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 20, 2007 12:40 am 
Newbie

Joined: Thu Apr 19, 2007 12:34 am
Posts: 8
thanks,thanx guys,my problem is resolved


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

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.