Hi all,
i am focusing an error, when trying to use ilike operator in a hql query.
I get everytime the message:
unexpected token: ilike
When using only like it works without any Problem.
Unfortunatly Postgres is using ilike as case sensitive, so I need to use ilike.
Is this a bug in the WhereParser ?
I was not able to find anything in the Threads...
Everyone in the Threads i found suggested using a Criteria and they are right it works in it, but I need to use it with a Query.
Thanks in advance.
Ali
Stats:
------------------------------------------
Hibernate version: 3.1.2[/b]
Code between sessionFactory.openSession() and session.close():
Query theQuery = theSession.createQuery("SELECT comp " +
"FROM Address adr, House h, Postcode pc, Street str, Town t, State sta, Country c, Company comp " +
"WHERE adr.houseid = h.id " +
"AND h.postcodeid = pc.id " +
"AND h.streetid = str.id " +
"AND str.townid = t.id " +
"AND t.stateid = sta.id " +
"AND sta.countryid = c.id " +
"AND pc.postcodenumber LIKE :postcodenumber " +
"AND t.name ilike :townname " +
"AND comp.adressesid = adr.adressid " +
"AND comp.name1 ilike :companyname " +
"ORDER BY comp.name1");
theQuery.setString("postcodenumber", postcodenumber+"%");
theQuery.setString("townname", townname+"%");
theQuery.setString("companyname", companyname+"%");
list=find(theSession, transaction, theQuery);
Exception:
Message
line 1:607: unexpected token: ilike
Database: PostgreSQL 8.1
The generated SQL :
SELECT comp FROM de.haiberg.adman.app.beans.adressbase.Address adr
, de.haiberg.adman.app.beans.adressbase.House h, de.haiberg.adman.app.beans.adressbase.Postcode pc, de.haiberg.adman.app.beans.adressbase.Street str, de.
haiberg.adman.app.beans.adressbase.Town t, de.haiberg.adman.app.beans.adressbase.State sta, de.haiberg.adman.app.beans.adressbase.Country c, de.haiberg.a
dman.app.beans.company.Company comp WHERE adr.houseid = h.id AND h.postcodeid = pc.id AND h.streetid = str.id AND str.townid = t.id AND t.stateid = sta.i
d AND sta.countryid = c.id AND pc.postcodenumber LIKE :postcodenumber AND t.name ilike :townname AND comp.adressesid = adr.adressid AND comp.name1 ilike
:companyname ORDER BY comp.name1
|