Remove some row selection uses

This commit is contained in:
Christian Beikov 2021-09-30 19:46:55 +02:00
parent c5baae7e11
commit 1246a22c83
2 changed files with 9 additions and 20 deletions

View File

@ -10,7 +10,8 @@ import java.sql.Types;
import org.hibernate.dialect.DB2Dialect; import org.hibernate.dialect.DB2Dialect;
import org.hibernate.engine.jdbc.Size; import org.hibernate.engine.jdbc.Size;
import org.hibernate.engine.spi.RowSelection; import org.hibernate.query.Limit;
import org.junit.Test; import org.junit.Test;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
@ -70,7 +71,7 @@ public class DB2DialectTestCase extends BaseUnitTestCase {
@Test @Test
@TestForIssue(jiraKey = "HHH-12369") @TestForIssue(jiraKey = "HHH-12369")
public void testIntegerOverflowForMaxResults() { public void testIntegerOverflowForMaxResults() {
RowSelection rowSelection = new RowSelection(); Limit rowSelection = new Limit();
rowSelection.setFirstRow(1); rowSelection.setFirstRow(1);
rowSelection.setMaxRows(Integer.MAX_VALUE); rowSelection.setMaxRows(Integer.MAX_VALUE);
String sql = dialect.getLimitHandler().processSql( "select a.id from tbl_a a order by a.id", rowSelection ); String sql = dialect.getLimitHandler().processSql( "select a.id from tbl_a a order by a.id", rowSelection );

View File

@ -7,8 +7,8 @@
package org.hibernate.orm.test.dialect; package org.hibernate.orm.test.dialect;
import org.hibernate.dialect.pagination.Oracle12LimitHandler; import org.hibernate.dialect.pagination.Oracle12LimitHandler;
import org.hibernate.engine.spi.QueryParameters; import org.hibernate.query.Limit;
import org.hibernate.engine.spi.RowSelection; import org.hibernate.query.spi.QueryOptions;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
@ -24,8 +24,7 @@ public class Oracle12LimitHandlerTest {
final String sql = "select p.name from Person p where p.id = 1 for update"; final String sql = "select p.name from Person p where p.id = 1 for update";
final String expected = "select * from (select p.name from Person p where p.id = 1) where rownum<=? for update"; final String expected = "select * from (select p.name from Person p where p.id = 1) where rownum<=? for update";
final QueryParameters queryParameters = getQueryParameters( 0, 5 ); final String processedSql = Oracle12LimitHandler.INSTANCE.processSql( sql, new Limit( 0, 5 ), QueryOptions.NONE );
final String processedSql = Oracle12LimitHandler.INSTANCE.processSql( sql, queryParameters );
assertEquals( expected, processedSql ); assertEquals( expected, processedSql );
} }
@ -35,8 +34,7 @@ public class Oracle12LimitHandlerTest {
final String sql = "select p.name from Person p where p.name = ' this is a string with spaces ' for update"; final String sql = "select p.name from Person p where p.name = ' this is a string with spaces ' for update";
final String expected = "select * from (select p.name from Person p where p.name = ' this is a string with spaces ') where rownum<=? for update"; final String expected = "select * from (select p.name from Person p where p.name = ' this is a string with spaces ') where rownum<=? for update";
final QueryParameters queryParameters = getQueryParameters( 0, 5 ); final String processedSql = Oracle12LimitHandler.INSTANCE.processSql( sql, new Limit( 0, 5 ), QueryOptions.NONE );
final String processedSql = Oracle12LimitHandler.INSTANCE.processSql( sql, queryParameters );
assertEquals( expected, processedSql ); assertEquals( expected, processedSql );
} }
@ -46,8 +44,7 @@ public class Oracle12LimitHandlerTest {
final String sql = "select a.prop from A a where a.name = 'this is for update '"; final String sql = "select a.prop from A a where a.name = 'this is for update '";
final String expected = "select a.prop from A a where a.name = 'this is for update ' fetch first ? rows only"; final String expected = "select a.prop from A a where a.name = 'this is for update ' fetch first ? rows only";
final QueryParameters queryParameters = getQueryParameters( 0, 5 ); final String processedSql = Oracle12LimitHandler.INSTANCE.processSql( sql, new Limit( 0, 5 ), QueryOptions.NONE );
final String processedSql = Oracle12LimitHandler.INSTANCE.processSql( sql, queryParameters );
assertEquals( expected, processedSql ); assertEquals( expected, processedSql );
} }
@ -57,18 +54,9 @@ public class Oracle12LimitHandlerTest {
final String sql = "select a.prop from A a where a.name = 'this is for update ' for update"; final String sql = "select a.prop from A a where a.name = 'this is for update ' for update";
final String expected = "select * from (select a.prop from A a where a.name = 'this is for update ') where rownum<=? for update"; final String expected = "select * from (select a.prop from A a where a.name = 'this is for update ') where rownum<=? for update";
final QueryParameters queryParameters = getQueryParameters( 0, 5 ); final String processedSql = Oracle12LimitHandler.INSTANCE.processSql( sql, new Limit( 0, 5 ), QueryOptions.NONE );
final String processedSql = Oracle12LimitHandler.INSTANCE.processSql( sql, queryParameters );
assertEquals( expected, processedSql ); assertEquals( expected, processedSql );
} }
private QueryParameters getQueryParameters(int firstRow, int maxRow) {
final QueryParameters queryParameters = new QueryParameters();
RowSelection rowSelection = new RowSelection();
rowSelection.setFirstRow( firstRow );
rowSelection.setMaxRows( maxRow );
queryParameters.setRowSelection( rowSelection );
return queryParameters;
}
} }