-->
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.  [ 3 posts ] 
Author Message
 Post subject: LIKE to ILIKE : how to use query.substitutions to solve it?
PostPosted: Thu Nov 16, 2006 1:17 pm 
Regular
Regular

Joined: Thu Jul 08, 2004 1:21 pm
Posts: 68
Location: Recife - Pernambuco - Brazil
Hibernate version: 3.1.3

Mapping documents: does not matter.

Name and version of the database you are using: PostgreSQL 8.1.3

The generated SQL (show_sql=true):

Hello, I have search forum before ask it, but I can't found a answer to my problem. We have used ilike operator in Hibernate 2.x and now, we are migrating to Hibernate 3.1.3 and ilike don't works anymore. I could correct a ton of HQL using some tool to do a replace but so, my queries will be not case insensitive. The scenario is:
1. Use criteria will take a lot of time because we must replace any query by code to use Criteria;
2. use "lower", "upper" functions will need a great effort to rewrite a ton of queries;
3. We have try to use query.substitutions in the following way:
Code:
hibernate.query.substitutions=like=ilike, random=random()

"random" works fine, but "like=ilike" don't. There is something wrong with query parser or I have missed some detail about query.substitutions? The docs say: "Mapping from tokens in Hibernate queries to SQL tokens"

What I have done wrong? :-(

Kind regards.

_________________
Marcos Silva Pereira
http://blastemica.blogspot.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 16, 2006 6:22 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You have done nothing wrong as such just caught up with a change in the parser. H3 uses a formal parser that is making sure the tokens are correct while H2 passed through anything it did not understand. ilike is not a reserved word so it H2 would pass it through and H3 will complain as it was expecting a valid token. H3 is correct in its approach.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 16, 2006 7:21 pm 
Regular
Regular

Joined: Thu Jul 08, 2004 1:21 pm
Posts: 68
Location: Recife - Pernambuco - Brazil
david wrote:
You have done nothing wrong as such just caught up with a change in the parser. H3 uses a formal parser that is making sure the tokens are correct while H2 passed through anything it did not understand. ilike is not a reserved word so it H2 would pass it through and H3 will complain as it was expecting a valid token. H3 is correct in its approach.

David, thanks, I catch it. :-)

But, how can I transpasse this chance in parser without doing a lot of work? I think that "query.substitutions" must work for my case, but it didn't. I wonder to know why random is replaced by "random()" and "like" is not replaced by "ilike".

Which approach you suggest to my case?

Kind Regads

_________________
Marcos Silva Pereira
http://blastemica.blogspot.com


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