[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6122) HSQLDialect uses wrong trim() function when running HSQLDB v1.8

Matthew Pies (JIRA) noreply at atlassian.com
Wed Apr 13 15:28:59 EDT 2011


HSQLDialect uses wrong trim() function when running HSQLDB v1.8
---------------------------------------------------------------

                 Key: HHH-6122
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6122
             Project: Hibernate Core
          Issue Type: Bug
          Components: query-hql
    Affects Versions: 3.6.0
         Environment: Maven: hibernate-core-3.6.0.Final.jar, hsqldb-1.8.0.10.jar
            Reporter: Matthew Pies


The default dialect behavior assumes the TRIM function has the form "TRIM(?1 ?2 ?3 ?4)", whereas HSQLDB v1.8 specifies: "TRIM([{LEADING | TRAILING | BOTH}] FROM <string expression>)" (http://www.hsqldb.org/doc/1.8/guide/ch09.html#stored-section).

Simply fixed in the HSQLDialect class constructor by overriding the function registered in the parent Dialect class:

    if ( hsqldbVersion < 20 ) { // maybe == 18? not sure best practice here...
        registerFunction("trim", new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(both from ?1)"));
    }

Simple test case (assuming HSQLDialect + HSQL JDBC driver):

    sessionFactory.getCurrentSession().createQuery("from User where trim(email) = 'foo at bar.com'").list();


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