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.  [ 2 posts ] 
Author Message
 Post subject: Does Hibernate treat "not exists" correctly???
PostPosted: Wed Feb 07, 2007 12:25 pm 
Newbie

Joined: Wed Mar 30, 2005 12:10 pm
Posts: 3
Location: Omaha, NE
Hi Everyone,

Working on an issue with Hibernate - we needed to do a change in a HQL that now includes a "not exists" to the HQL. If I pull the HQL and put it as SQL, it functions properly - but when I run the app itself, it returns no rows.

Here is the HQL:

"from " + trafficStatus.class.getName() + " s, " + eventQueue.class.getName() + " b " +
"where s.availableFlag = 'Y' " +
"and s.deliveryFlag = 'Y' " +
"and s.code= b.code" +
"and b.processedFlag = 'N' " +
"and (not exists (SELECT c.value " +
"from " + config.class.getName() + " c " +
"where c.code= b.code" +
" and c.pmsType = 'O' " +
" and c.key = 'key' " +
" and c.value = 'Y') " +
"or b.createdTimestamp < :timeDelayDate) ";


Any ideas about this "not exists" problem?

Thanks, Michael


Top
 Profile  
 
 Post subject: Found the solution...
PostPosted: Wed Feb 07, 2007 4:13 pm 
Newbie

Joined: Wed Mar 30, 2005 12:10 pm
Posts: 3
Location: Omaha, NE
Well - one needed piece of information is

Code:
   long lDelay = new Long(1*60*1000L);
   Date lTimeDelayDate = new Date(new Date().getTime() - lDelay);
   List lList = pSession.createQuery(HQL_QUEUE)
            .setDate("timeDelayDate", lTimeDelayDate).setMaxResults(1).list();


The code was trying to exclude rows that didn't have have a created date of less than a minute (yeah, crazy, but that is what the business needs). Using the "setDate" apparently was striping off the time value and messing up the comparsion and not returning any rows. Changing it to either setTime or setParameter resulted in the rows being returned.

Therefore - BE careful setting values on the HQL...

Michael


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.