[Hibernate-JIRA] Created: (HHH-6024) NPE in CastFunction when casting a field named "date" to type "date" in HQL
by Jon Mann (JIRA)
NPE in CastFunction when casting a field named "date" to type "date" in HQL
---------------------------------------------------------------------------
Key: HHH-6024
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6024
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.6.2
Environment: Hibernate 3.6.0.Final and 3.6.2.Final
MySQL 5.0
Reporter: Jon Mann
Attachments: hibernate-cast-date.zip
In Hibernate version "3.6.2.Final" when casting a field named "date" to type "date":
SELECT entity FROM DateEntity AS entity WHERE CAST(entity.date AS date) = ?
we encounter a NullPointerException in CastFunction:
java.lang.NullPointerException
at org.hibernate.dialect.function.CastFunction.render(CastFunction.java:56)
at org.hibernate.hql.ast.SqlGenerator.endFunctionTemplate(SqlGenerator.java:214)
at org.hibernate.hql.antlr.SqlGeneratorBase.methodCall(SqlGeneratorBase.java:2325)
...
If we rename the field "date" to "creationDate", the problem dissapears.
If we cast to "time" instead of "date", the problem dissapears.
We encountered this problem while using Hibernate version "3.6.0.Final" against MySQL 5.0.
Upgrading to Hibernate version "3.6.2.Final" did not resolve the problem.
We guess this problem is a bug in the Hibernate HQL parsing code. It might be a problem with our usage of Hibernate, in which case it would be helpful for Hibernate to return a useful error message.
Please find attached a minimal Maven test case (using HSQL memory DB) which demonstrates the problem.
The following JIRA issue maybe related to this problem:
HHH-3770 - NPE in o.h.dialect.function.CastFunction
Credit to my colleague Sergey Shinkevich for creating the test case.
Thanks to the Hibernate team for a great product.
--
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years