-->
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.  [ 5 posts ] 
Author Message
 Post subject: Escaping colons : using createSQLQuery in hibernate 3.0
PostPosted: Fri Feb 11, 2005 5:42 pm 
Newbie

Joined: Thu Dec 30, 2004 3:51 pm
Posts: 14
Hibernate version:
3.0

Name and version of the database you are using:
DB2 UDB for AS/400 05.02.0000 V5R2m0 AS/400 Toolbox for Java JDBC Driver 6.0

The generated SQL (show_sql=true):

Hi,

How do you escape colons (:) when using the createSQLQuery command?
Right now it is replacing the : with a ? in the string

for example:

sql = "select { tbl.* } from table1 where COL1 = 'THING: THANG'

Query query = session.createSQLQuery(sql, "tbl", MyClass.class);

the output is:
select tbl.COL1 as COL10_, tbl.COL2 as COL20_ from table1 tbl where COL10 = 'THING? THANG'

i tried using \ to escape it, but then i end up with:
select tbl.COL1 as COL10_, tbl.COL2 as COL20_ from table1 tbl where COL10 = 'THING\: THANG'

which is no good either

i searched the forums and jira and it seems this issue was addressed:
http://opensource.atlassian.com/project ... se/HB-1042

but it's does not seem to be working
any ideas?

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 7:05 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
how about using a parameter

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 12:06 pm 
Newbie

Joined: Sat Jan 15, 2005 12:47 pm
Posts: 6
emmanuel wrote:
how about using a parameter

This may Help for this Problem, but in general there is a need for escape character in general for Hibernate specific characters.

In this case colon ":",
in case of a SqlQuery it can happen that you need to wirte a specific Query which needs colons.

for example casting in Postgres:

A query like
"SELECT number::int4 From numbers "

is not performable (::int4 is for casting the Value to integer).

Of course there are workarounds, but such a query should be performable in Hibernate.

At present with hibernate3 it is not !


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 4:58 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
open a JIRA issue

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Escaping the colon character for SQLQuery
PostPosted: Thu Nov 08, 2007 5:59 pm 
Newbie

Joined: Thu Jul 28, 2005 7:15 pm
Posts: 2
Has the issue of escaping the colon character been resolved?

I am using Eclipse SDK
Version: 3.2.0
Build id: M20060629-1905

The SQLQuery statement for a native MSSQL 2005 I am trying to use is:

select top 10 MyTable.GUID as GUID0_ where MyTable.myDate < cast('2007/11/08 01:24:35' as datetime)

The Hibernate 3.2.0 translate it into:

select top 10 MyTable.GUID as GUID0_ where MyTable.myDate < cast('2007/11/08 01?' as datetime)

which of course failed the query.

Is this issue resolved?

Thanks for your help.
Shuh


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