-->
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: Is there a numerical wildcard in HQL for oracle
PostPosted: Wed Dec 29, 2004 5:19 am 
Newbie

Joined: Wed Dec 29, 2004 4:59 am
Posts: 1
Hibernate version: 2.1.2

Oracle 9i release 2

I have to rewrite a large (100s) number of HQL queries in a project.
These all use a number of possible query values.

eg:

from dataStore as db1, datastore2 as db2
where
db.label = 'some string' and
db.label2 = 'some string as well' and
(db.id = anID or
db.id = anotherID or
db.id = a3rdID) and
db2.label = 'string'and
db2.id = ID4
...

you get the picture.

the problem:
any or all of these values(string and int) may be specified or empty...

at the moment they are using stringbuffer and appending the HQL as is neccessary.
however, the client wants to change to named variables.
and make it all clearer

I can use the standard '%' wildcard in a ternary statement for the string values...

Query q;
String qS = new String("from db where db.code = :code")
q = session.createQuery (qS);
q.setString("code",(code.length() >=1 ? code : "%" ));

but I am searching for a way to do the same with numbers...
The major problem I am running into is putting a numerical wildcard into the named parameter. I can't find one.
I have looked everywhere to no avail, so now I am asking here.

Any Ideas will be most welcome.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 27, 2005 10:22 am 
Newbie

Joined: Fri May 27, 2005 10:12 am
Posts: 1
Hi,

To be able to use the "%" wildcard for numbers I would enhance your HQL queries like this:

"from db where to_char(db.code) like :code"

I'm using Hibernate 3.0 and Oracle 8i, and there this works.


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.