Hi,
Hibernate version: 3.3.2 GA
I'm 99% sure I've discovered a bug in hibernate's row value constructor syntax. Following SQL statement (Oracle) is going to cause an exception:
Code:
select *
from some_table t
where t.date_like_field = :some_value
, where t.date_like_field is being replaced by "(extract(year from t.some_date), extract(month from t.some_date)" (noop component)
An Exception:
Code:
Caused by: org.hibernate.HibernateException: SqlNode's text did not reference expected number of columns
at org.hibernate.hql.ast.tree.BinaryLogicOperatorNode.extractMutationTexts(BinaryLogicOperatorNode.java:198)
at org.hibernate.hql.ast.tree.BinaryLogicOperatorNode.mutateRowValueConstructorSyntax(BinaryLogicOperatorNode.java:118)
at org.hibernate.hql.ast.tree.BinaryLogicOperatorNode.mutateRowValueConstructorSyntaxesIfNecessary(BinaryLogicOperatorNode.java:94)
at org.hibernate.hql.ast.tree.BinaryLogicOperatorNode.initialize(BinaryLogicOperatorNode.java:74)
at org.hibernate.hql.ast.HqlSqlWalker.prepareLogicOperator(HqlSqlWalker.java:1133)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4189)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1864)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1792)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:818)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:604)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:288)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:231)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1651)
And the culprit imho is the following line of code [ org.hibernate.hql.ast.tree.BinaryLogicOperatorNode (Line 196) ]:
Code:
String[] splits = StringHelper.split( ", ", nodeText );
I can only assume that somebody thought 'StringHelper.split' works the same way as 'String#split', whereas the former accepts string with separators as an argument and the latter accepts regex as a separator.