[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5970) Error in filter-def condition attribute definition caused by trim sql function

Tomáš Šafařík (JIRA) noreply at atlassian.com
Tue Mar 1 05:45:08 EST 2011


Error in filter-def condition attribute definition caused by trim sql function
------------------------------------------------------------------------------

                 Key: HHH-5970
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5970
             Project: Hibernate Core
          Issue Type: Bug
          Components: core
    Affects Versions: 3.6.0
            Reporter: Tomáš Šafařík


I have encountered an error that in filter-def definition in condition attribute is not possible to use SQL function trim with expression. 
For example this definition: <filter-def name="concatInTrim" condition="TRIM(CONCAT(TITLE,TITLE)) IS NOT NULL" /> causes this error:

-------------------------------------------------------------------------------
Test set: org.hibernate.test.function.trim.FunctionTrimTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.698 sec <<< FAILURE!
testBasicUsage(org.hibernate.test.function.trim.FunctionTrimTest)  Time elapsed: 0.659 sec  <<< ERROR!
org.hibernate.HibernateException: Unexpected number of trim function operands : 5
	at org.hibernate.sql.Template$TrimOperands.<init>(Template.java:582)
	at org.hibernate.sql.Template$TrimOperands.<init>(Template.java:561)
	at org.hibernate.sql.Template.renderWhereStringTemplate(Template.java:248)
	at org.hibernate.util.FilterHelper.<init>(FilterHelper.java:63)
	at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:737)
	at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:133)
	at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:284)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842)
	at org.hibernate.test.function.trim.FunctionTrimTest.setUp(FunctionTrimTest.java:24)
	at junit.framework.TestCase.runBare(TestCase.java:132)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:232)
	at junit.framework.TestSuite.run(TestSuite.java:227)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102)
	at org.apache.maven.surefire.Surefire.run(Surefire.java:180)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
	at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)

I think, that this problem is caused by function org.hibernate.sql.Template.renderWhereStringTemplate(), that doesn't take into account possibility of expression in trim function argument.
I think that this problem is related to http://opensource.atlassian.com/projects/hibernate/browse/HHH-5676?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#issue-tabs.
In attachment is test case based on Hibernate tutorial (hbm.xml Tutorial).


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