javax.persistence.criteria.Expression.as() is broken
Description
When I try to execute criteria query containing typecast to String
I get the following exception
org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found '(' near line 1, column 132 [select generatedAlias0 from org.hibernate.ejb.metamodel.Product as generatedAlias0 where cast(generatedAlias0.partNumber as varchar(255)) like aram0]
As you can see, SQL type is used in HQL cast clause. It's caused by CriteriaQueryCompiler.RenderingContext.getCastType() that erroneously return SQL typename instead of Hibernate typename.
Attachments
1
Activity
JacobHSeptember 22, 2014 at 2:52 AM
Please ignore this. Even though I updated my version on hibernate in the pom.xml file using org.hibernate.annotations.common.Version.getVersionString() I see we're still using 4.0.1.Final. I think this is because we are using Spring and it is ignoring the version of hibernate in our pom.xml file.
JacobHSeptember 20, 2014 at 9:09 AM
I just upgraded our code to 4.3.6.Final and the bug still exists. Can we repopen this?
JacobHSeptember 20, 2014 at 8:10 AM
We're using 4.1.9.Final and seeing the exact same problem. Is this a known issue for 4.1.9.Final?
Ideally if the bug is fixed in the latest version 4.3.6.Final we'd just upgrade to that, but there seem to be some compatibility issues between our version of Spring and the 4.3.6.Final version of Hibernate.
When I try to execute criteria query containing typecast to
String
I get the following exception
As you can see, SQL type is used in HQL
cast
clause. It's caused byCriteriaQueryCompiler.RenderingContext.getCastType()
that erroneously return SQL typename instead of Hibernate typename.