[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3336) LIKE checks with component values

Maxx (JIRA) noreply at atlassian.com
Fri Jun 6 14:15:33 EDT 2008


LIKE  checks with component values
----------------------------------

                 Key: HHH-3336
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3336
             Project: Hibernate3
          Issue Type: Improvement
          Components: query-hql
    Affects Versions: 3.2.5
         Environment: Hibernate 3.2.5
Oracle 10i
            Reporter: Maxx


In the same way than a previous "issue" i.e. http://opensource.atlassian.com/projects/hibernate/browse/HHH-2826
it would be very helpful if the HQL translator would "explode" a LIKE instruction on each property of a component, rather than just using the equal "=".

Let's say a Person with a name property (component type "Name") and the corresponding HQL query:
... from Person p where p.name like ('Jo%n', 'Schm%')
This uses the "row value constructor" as described here: http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html#queryhql-tuple

Currently, the resulting SQL is something like:
... from Person p where p.f_name = 'Jo%n' and p.l_name = 'Schm%'
which is wrong as we've lost the purpose of the wildcard '%'

=> In this case, it just won't return the good results, but when the properties (here f_name, l_name) are something other than a String/VARCHAR (e.g. an INTEGER) it sometimes throws an error (like: % is not a number) ..!

The expected translation would be something like:
... from Person p where p.f_name LIKE 'Jo%n' and p.l_name LIKE 'Schm%'

I personally faced this case as I have an enumeration (enum, Java5) representing a set of business values, each mapped to a single sql column; as I don't want to list the name of ALL component properties (they are numerous, and easily iterable - thanks to the enum) and the "row value constructor" syntax is much easier to use in this case.

-- 
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