reset the ValueHandlingMode after pagination

This commit is contained in:
Gavin King 2024-09-09 23:37:58 +02:00
parent 9f91f2dbff
commit 6d4002bd97
3 changed files with 14 additions and 4 deletions

View File

@ -17,6 +17,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.hibernate.Internal;
import org.hibernate.jpa.spi.JpaCompliance; import org.hibernate.jpa.spi.JpaCompliance;
import org.hibernate.metamodel.model.domain.JpaMetamodel; import org.hibernate.metamodel.model.domain.JpaMetamodel;
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode; import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
@ -89,7 +90,8 @@ public interface NodeBuilder extends HibernateCriteriaBuilder, BindingContext {
QueryEngine getQueryEngine(); QueryEngine getQueryEngine();
void setCriteriaValueHandlingMode(ValueHandlingMode criteriaValueHandlingMode); @Internal
ValueHandlingMode setCriteriaValueHandlingMode(ValueHandlingMode criteriaValueHandlingMode);
<R> SqmTuple<R> tuple( <R> SqmTuple<R> tuple(
Class<R> tupleType, Class<R> tupleType,

View File

@ -166,8 +166,13 @@ abstract class AbstractSqmSelectionQuery<R> extends AbstractSelectionQuery<R> {
getSqmSelectStatement().copy( noParamCopyContext() ); getSqmSelectStatement().copy( noParamCopyContext() );
final NodeBuilder builder = sqm.nodeBuilder(); final NodeBuilder builder = sqm.nodeBuilder();
//TODO: find a better way handle parameters //TODO: find a better way handle parameters
builder.setCriteriaValueHandlingMode(ValueHandlingMode.INLINE); final ValueHandlingMode valueHandlingMode = builder.setCriteriaValueHandlingMode(ValueHandlingMode.INLINE);
return paginate( keyDefinition, keyValues, sqm, builder ); try {
return paginate( keyDefinition, keyValues, sqm, builder );
}
finally {
builder.setCriteriaValueHandlingMode( valueHandlingMode );
}
} }

View File

@ -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; this.criteriaValueHandlingMode = criteriaValueHandlingMode;
return current;
} }
@Override @Override