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: I get "?" in actual query in DB in convert(datetime where cl
PostPosted: Wed Jan 05, 2011 3:29 pm 
Newbie

Joined: Wed Jan 05, 2011 3:22 pm
Posts: 13
Hi

I have a native sql query with count(*) in which I have datetime criteria converted using MS SQL function Convert(datetime..) while in debug I see the query properly formatted in "Query object" but as soon as I used list() function I get exception saying "[SQLServer JDBC Driver][SQLServer]Conversion failed when converting datetime from character string.". So If I check my Jboss logs I see my query has extra "?" in date string

my original query before executing ( I have my where clause ready in String already)

SELECT count(*) as mycount FROM rptdepositSummary
WHERE depClassId = 8 AND bankid = 2600000000001 AND depStatus IN (3,6,7)
AND (createDate BETWEEN Convert(datetime ,'2010-December-13 05:00:00')
AND Convert(datetime ,'2011-January-06 04:59:59.999'))

And After (in jboss logs)

SELECT count(*) as mycount FROM rptdepositSummary
WHERE depClassId = 8 AND bankid = 2600000000001 AND depStatus IN (3,6,7)
AND (createDate BETWEEN Convert(datetime ,'2010-December-13 05?')
AND Convert(datetime ,'2011-January-06 04?'))

My code is as below

Query query = HibernateUtility.currentSession().createSQLQuery(queryString);
((SQLQuery) query).addScalar("mycount", Hibernate.INTEGER);
Collection<?> results = (Collection<?>) query.uniqueResult();
int size = Integer.parseInt(results.iterator().next().toString());

Im using Hibernate 3.

Any help is appreciated


Top
 Profile  
 
 Post subject: Re: I get "?" in actual query in DB in convert(datetime where cl
PostPosted: Fri Jan 07, 2011 2:40 pm 
Newbie

Joined: Wed Jan 05, 2011 3:22 pm
Posts: 13
looks like im running into this escape sequence issue for named paramenters where Hibernate is thinking in time (HH:MM:SS) it adds "?" and chop off the rest of the value after first occurrence of ":"

found this viewtopic.php?p=2249465

not sure the last solution works or not but will give a try


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.