[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5339) Restrictions.ilike doesn't work on integer columns

Chris Wilson (JIRA) noreply at atlassian.com
Thu Jun 24 05:33:09 EDT 2010


Restrictions.ilike doesn't work on integer columns
--------------------------------------------------

                 Key: HHH-5339
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5339
             Project: Hibernate Core
          Issue Type: Bug
            Reporter: Chris Wilson


Hibernate doesn't like using {@link Restrictions#ilike} on integer columns.

It uses the SQL lowercase function on the column, the result of which
must be a character type (CHAR or VARCHAR) because:

bq. LOWER Converts a string to all lowercase characters ([SQL in a Nutshell|http://oreilly.com/catalog/sqlnut/chapter/ch04.html])

But IlikeExpression.getTypedValues() asks the criteria query for the type of the typed values, which returns the underlying type, which in this case is an integer type.

Hibernate then throws a ClassCastException, trying to fit the string parameter into an Integer TypedValue:

* java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
* at org.hibernate.type.IntegerType.set(IntegerType.java:64)
* at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:154)
* at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
* at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1732)
* at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1703)
* at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1593)
* at org.hibernate.loader.Loader.doQuery(Loader.java:696)
* at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
* at org.hibernate.loader.Loader.doList(Loader.java:2232)
* at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
* at org.hibernate.loader.Loader.list(Loader.java:2124)
* at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
* at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1597)
* at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
* at org.wfp.rita.datafacade.RequestDao.listRequests(RequestDao.java:736)

I can't give you a patch because I can't build Hibernate because the actual instructions are missing from [http://www.hibernate.org/sourcecode.html]. I'll attach the test in a second.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list