From 3f20292fb5513cade66006ab2378424ee917be95 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Mon, 10 Nov 2008 18:14:18 +0000 Subject: [PATCH] HHH-530 : problem with parameter-pulling when row value constructor morphed on dialects not supporting git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@15538 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../hql/ast/tree/BinaryLogicOperatorNode.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/hibernate/hql/ast/tree/BinaryLogicOperatorNode.java b/core/src/main/java/org/hibernate/hql/ast/tree/BinaryLogicOperatorNode.java index 66aebb189b..769b240ff1 100644 --- a/core/src/main/java/org/hibernate/hql/ast/tree/BinaryLogicOperatorNode.java +++ b/core/src/main/java/org/hibernate/hql/ast/tree/BinaryLogicOperatorNode.java @@ -20,7 +20,6 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.hql.ast.tree; @@ -28,6 +27,7 @@ import org.hibernate.Hibernate; import org.hibernate.TypeMismatchException; import org.hibernate.HibernateException; +import org.hibernate.param.ParameterSpecification; import org.hibernate.util.StringHelper; import org.hibernate.hql.antlr.HqlSqlTokenTypes; import org.hibernate.engine.SessionFactoryImplementor; @@ -117,9 +117,18 @@ private void mutateRowValueConstructorSyntax(int valueElements) { String[] lhsElementTexts = extractMutationTexts( getLeftHandOperand(), valueElements ); String[] rhsElementTexts = extractMutationTexts( getRightHandOperand(), valueElements ); + ParameterSpecification lhsEmbeddedCompositeParameterSpecification = + getLeftHandOperand() == null || ( !ParameterNode.class.isInstance( getLeftHandOperand() ) ) + ? null + : ( ( ParameterNode ) getLeftHandOperand() ).getHqlParameterSpecification(); + + ParameterSpecification rhsEmbeddedCompositeParameterSpecification = + getRightHandOperand() == null || ( !ParameterNode.class.isInstance( getRightHandOperand() ) ) + ? null + : ( ( ParameterNode ) getRightHandOperand() ).getHqlParameterSpecification(); + AST container = this; for ( int i = valueElements - 1; i > 0; i-- ) { - if ( i == 1 ) { AST op1 = getASTFactory().create( comparisonType, comparisonText ); AST lhs1 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, lhsElementTexts[0] ); @@ -133,6 +142,16 @@ private void mutateRowValueConstructorSyntax(int valueElements) { op2.setFirstChild( lhs2 ); lhs2.setNextSibling( rhs2 ); op1.setNextSibling( op2 ); + + // "pass along" our initial embedded parameter node(s) to the first generated + // sql fragment so that it can be handled later for parameter binding... + SqlFragment fragment = ( SqlFragment ) lhs1; + if ( lhsEmbeddedCompositeParameterSpecification != null ) { + fragment.addEmbeddedParameter( lhsEmbeddedCompositeParameterSpecification ); + } + if ( rhsEmbeddedCompositeParameterSpecification != null ) { + fragment.addEmbeddedParameter( rhsEmbeddedCompositeParameterSpecification ); + } } else { AST op = getASTFactory().create( comparisonType, comparisonText );