Bug 1077140

Summary: [HHH-9052] Unsupported SQL generated when constructors are used with predicates as arguments
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Jan Martiska <jmartisk>
Component: HibernateAssignee: Brett Meyer <brmeyer>
Status: CLOSED CURRENTRELEASE QA Contact: Jan Martiska <jmartisk>
Severity: high Docs Contact: Russell Dickenson <rdickens>
Priority: unspecified    
Version: 6.3.0CC: msimka, theute
Target Milestone: DR6   
Target Release: EAP 6.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-28 15:28:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1073085    

Description Jan Martiska 2014-03-17 10:40:23 UTC
org.hibernate.test.hql.ASTParserLoadingTest.testBooleanPredicate fails on most databases (all except postgres and mysql) due to:

05:19:00,795 DEBUG QueryTranslatorImpl:237 - HQL: select new Constructor( c.id, c.id is not null, c.id = c.id, c.id + 1, concat( c.id, 'foo' ) ) from org.hibernate.test.hql.Constructor c where c.id = :id
05:19:00,795 DEBUG QueryTranslatorImpl:238 - SQL: select constructo0_.ID as col_0_0_, constructo0_.ID is not null as col_1_0_, constructo0_.ID=constructo0_.ID as col_2_0_, constructo0_.ID+1 as col_3_0_, constructo0_.ID||'foo' as col_4_0_ from Constructor constructo0_ where constructo0_.ID=?
(...)
05:19:00,797  WARN SqlExceptionHelper:144 - SQL Error: 923, SQLState: 42000
05:19:00,797 ERROR SqlExceptionHelper:146 - ORA-00923: FROM keyword not found where expected

It seems that '$column=$othercolumn' and '$column is not null' predicates are not supported by these databases..

Comment 1 Brett Meyer 2014-03-17 19:21:47 UTC
Corrected upstream and will be a part of the ORM component upgrade in 1073085

Comment 2 Brett Meyer 2014-03-17 19:22:20 UTC
Test-only fix -- no docs required

Comment 4 Jan Martiska 2014-03-28 13:29:15 UTC
org.hibernate.ejb.criteria.QueryBuilderTest.testMultiselectWithPredicates still fails with the same cause on Hibernate 4.2.11.Final. Sorry I didn't mention it here and not emphatically enough on the JIRA :(

16:12:19,798 DEBUG QueryTranslatorImpl:237 - HQL: select new org.hibernate.ejb.metamodel.Customer(generatedAlias0.id, generatedAlias0.name, :param0 || generatedAlias0.name, generatedAlias0.age is not null) from org.hibernate.ejb.metamodel.Customer as generatedAlias0
16:12:19,798 DEBUG QueryTranslatorImpl:238 - SQL: select customer0_.ID as col_0_0_, customer0_.NAME as col_1_0_, ?||customer0_.NAME as col_2_0_, customer0_.AGE is not null as col_3_0_ from CUSTOMER_TABLE customer0_
(...)
16:12:19,806 DEBUG SqlExceptionHelper:138 - could not extract ResultSet [n/a]
java.sql.SQLSyntaxErrorException: ORA-00923: FROM keyword not found where expected

Comment 5 Brett Meyer 2014-03-28 15:31:07 UTC
Jan, you had only mentioned ASTParserLoadingTest.testBooleanPredicate both here and on the upstream JIRA.  This is the first time QueryBuilderTest.testMultiselectWithPredicates was brought up.  Since ASTParserLoadingTest was already corrected in DR6, I'd recommend resolving this BZ and opening a new one for a future EAP release, especially since it's a test-only fix.

Comment 6 Jan Martiska 2014-03-28 15:38:37 UTC
Ok then, sorry for being not verbose enough. Will create a new one.