diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/NodeBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/NodeBuilder.java index 83dcf96ad0..ba28971fd3 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/NodeBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/NodeBuilder.java @@ -17,6 +17,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.hibernate.Internal; import org.hibernate.jpa.spi.JpaCompliance; import org.hibernate.metamodel.model.domain.JpaMetamodel; import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode; @@ -89,7 +90,8 @@ public interface NodeBuilder extends HibernateCriteriaBuilder, BindingContext { QueryEngine getQueryEngine(); - void setCriteriaValueHandlingMode(ValueHandlingMode criteriaValueHandlingMode); + @Internal + ValueHandlingMode setCriteriaValueHandlingMode(ValueHandlingMode criteriaValueHandlingMode); SqmTuple tuple( Class tupleType, diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/AbstractSqmSelectionQuery.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/AbstractSqmSelectionQuery.java index 628f9dfad3..d1d5d814b4 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/AbstractSqmSelectionQuery.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/AbstractSqmSelectionQuery.java @@ -166,8 +166,13 @@ abstract class AbstractSqmSelectionQuery extends AbstractSelectionQuery { getSqmSelectStatement().copy( noParamCopyContext() ); final NodeBuilder builder = sqm.nodeBuilder(); //TODO: find a better way handle parameters - builder.setCriteriaValueHandlingMode(ValueHandlingMode.INLINE); - return paginate( keyDefinition, keyValues, sqm, builder ); + final ValueHandlingMode valueHandlingMode = builder.setCriteriaValueHandlingMode(ValueHandlingMode.INLINE); + try { + return paginate( keyDefinition, keyValues, sqm, builder ); + } + finally { + builder.setCriteriaValueHandlingMode( valueHandlingMode ); + } } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmCriteriaNodeBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmCriteriaNodeBuilder.java index c6ea2d4f60..555c6553d9 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmCriteriaNodeBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmCriteriaNodeBuilder.java @@ -241,8 +241,11 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext, } } - public void setCriteriaValueHandlingMode(ValueHandlingMode criteriaValueHandlingMode) { + @Override + public ValueHandlingMode setCriteriaValueHandlingMode(ValueHandlingMode criteriaValueHandlingMode) { + ValueHandlingMode current = this.criteriaValueHandlingMode; this.criteriaValueHandlingMode = criteriaValueHandlingMode; + return current; } @Override