|
190 | 190 | import org.hibernate.sql.exec.internal.AbstractJdbcParameter;
|
191 | 191 | import org.hibernate.sql.exec.internal.JdbcOperationQueryInsertImpl;
|
192 | 192 | import org.hibernate.sql.exec.internal.JdbcParameterBindingImpl;
|
| 193 | +import org.hibernate.sql.exec.internal.JdbcParameterImpl; |
193 | 194 | import org.hibernate.sql.exec.internal.JdbcParametersImpl;
|
194 | 195 | import org.hibernate.sql.exec.internal.SqlTypedMappingJdbcParameter;
|
195 | 196 | import org.hibernate.sql.exec.spi.ExecutionContext;
|
@@ -6853,9 +6854,21 @@ private int getSortSelectionIndex(QuerySpec querySpec, SortSpecification sortSpe
|
6853 | 6854 |
|
6854 | 6855 | private boolean isFetchFirstRowOnly(QueryPart queryPart) {
|
6855 | 6856 | return queryPart.getFetchClauseType() == FetchClauseType.ROWS_ONLY
|
6856 |
| - && queryPart.getFetchClauseExpression() instanceof QueryLiteral<?> |
| 6857 | + && ( queryPart.getFetchClauseExpression() instanceof QueryLiteral<?> |
6857 | 6858 | && Integer.valueOf( 1 )
|
6858 |
| - .equals( ( (QueryLiteral<?>) queryPart.getFetchClauseExpression() ).getLiteralValue() ); |
| 6859 | + .equals( ( (QueryLiteral) queryPart.getFetchClauseExpression() ).getLiteralValue() ) |
| 6860 | + || queryPart.getFetchClauseExpression() instanceof SqmParameterInterpretation |
| 6861 | + && isParameterValueEqualToOne( (SqmParameterInterpretation) queryPart.getFetchClauseExpression() ) |
| 6862 | + ); |
| 6863 | + } |
| 6864 | + |
| 6865 | + private boolean isParameterValueEqualToOne(SqmParameterInterpretation sqmParameterInterpretation) { |
| 6866 | + if ( sqmParameterInterpretation.getResolvedExpression() instanceof JdbcParameterImpl ) { |
| 6867 | + assert jdbcParameterBindings != null; |
| 6868 | + final JdbcParameterBinding binding = jdbcParameterBindings.getBinding( (JdbcParameterImpl)sqmParameterInterpretation.getResolvedExpression() ); |
| 6869 | + return binding != null && Integer.valueOf( 1 ).equals( binding.getBindValue() ); |
| 6870 | + } |
| 6871 | + return false; |
6859 | 6872 | }
|
6860 | 6873 |
|
6861 | 6874 | private SelectStatement stripToSelectClause(SelectStatement statement) {
|
|
0 commit comments