-->
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: Hql "Cast As" problem
PostPosted: Fri Oct 30, 2009 10:24 am 
Newbie

Joined: Fri Oct 30, 2009 9:45 am
Posts: 1
I have a problem with a query that matchs a blob column with a String parameter using the a like sentence in db2:

LOWER(CAST(SUBSTR(detail,1,32000) AS string)) LIKE LOWER(:detail)

I need to do the cast because if I use "detail LIKE BLOB(:detail)" insted, this query is case sensitive and i need a case insensitive query.

This is the xml associated with the blob column:

<property name="detail" type="byte[]">
<column name="DETAIL" not-null="true" />
</property>

When I ejecute the query, the translated sql is LOWER(CAST(SUBSTR(detail,1,32000) AS varchar(255))) LIKE :detail
but I need to cast as varchar(32000).

Does anyone knows how I can do that? If I use a custom type as second argument of the Cast function, hibernate throws NullPointerException

I don't speek English, so If I don't make me understand, I ask for apologies.


Top
 Profile  
 
 Post subject: Re: Hql "Cast As" problem
PostPosted: Wed Nov 11, 2009 4:32 pm 
Newbie

Joined: Wed Nov 11, 2009 1:07 pm
Posts: 3
Hi,
I have expirience with porting application on DB2. It's night mare :) One of the issue was exaclly the same as you mentioned. There is general rule to not use a markers (':param') as a parameter of DB function. Of course you can use cast but is not clear and maybe cause another problem during maintenance. The best solution is (in your case) use simple marker (:param) and use lower() or upper() method in bustness logic e.g. Java ;)
HTH


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.