HHH-12369 Testcase that ensures the max rows don't overflow

This commit is contained in:
Christian Beikov 2018-03-07 18:44:50 +01:00 committed by Andrea Boriero
parent 690fb6c334
commit 5aaabb0f03
1 changed files with 15 additions and 0 deletions

View File

@ -8,6 +8,7 @@ package org.hibernate.dialect;
import java.sql.Types;
import org.hibernate.engine.spi.RowSelection;
import org.junit.Test;
import org.hibernate.mapping.Column;
@ -15,6 +16,7 @@ import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* DB2 dialect related test cases
@ -63,4 +65,17 @@ public class DB2DialectTestCase extends BaseUnitTestCase {
actual
);
}
@Test
@TestForIssue(jiraKey = "HHH-12369")
public void testIntegerOverflowForMaxResults() {
RowSelection rowSelection = new RowSelection();
rowSelection.setFirstRow(1);
rowSelection.setMaxRows(Integer.MAX_VALUE);
String sql = dialect.getLimitHandler().processSql( "select a.id from tbl_a a order by a.id", rowSelection );
assertTrue(
"Integer overflow for max rows in: " + sql,
sql.contains("fetch first 2147483647 rows only")
);
}
}