use of org.hibernate.query.spi.Limit in project hibernate-orm by hibernate.
the class Oracle12LimitHandlerTest method testSqlWithForUpdateInsideQuotedString.
@Test
public void testSqlWithForUpdateInsideQuotedString() {
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 processedSql = Oracle12LimitHandler.INSTANCE.processSql(sql, new Limit(0, 5), QueryOptions.NONE);
assertEquals(expected, processedSql);
}
use of org.hibernate.query.spi.Limit in project hibernate-orm by hibernate.
the class SQLServer2005DialectTestCase method testGetLimitStringUsingCTEQueryNoOffset.
@Test
@TestForIssue(jiraKey = "HHH-8916")
public void testGetLimitStringUsingCTEQueryNoOffset() {
Limit selection = toRowSelection(0, 5);
// test top-based CTE with single CTE query_ definition with no odd formatting
final String query1 = "WITH a (c1, c2) AS (SELECT c1, c2 FROM t) SELECT c1, c2 FROM a";
assertEquals("WITH a (c1, c2) AS (SELECT c1, c2 FROM t) SELECT top(?) c1, c2 FROM a", dialect.getLimitHandler().processSql(query1, selection));
// test top-based CTE with single CTE query_ definition and various tab, newline spaces
final String query2 = " \n\tWITH a (c1\n\t,c2)\t\nAS (SELECT\n\tc1,c2 FROM t)\t\nSELECT c1, c2 FROM a";
assertEquals("WITH a (c1\n\t,c2)\t\nAS (SELECT\n\tc1,c2 FROM t)\t\nSELECT top(?) c1, c2 FROM a", dialect.getLimitHandler().processSql(query2, selection));
// test top-based CTE with multiple CTE query_ definitions with no odd formatting
final String query3 = "WITH a (c1, c2) AS (SELECT c1, c2 FROM t1), b (b1, b2) AS (SELECT b1, b2 FROM t2) " + "SELECT c1, c2, b1, b2 FROM t1, t2 WHERE t1.c1 = t2.b1";
assertEquals("WITH a (c1, c2) AS (SELECT c1, c2 FROM t1), b (b1, b2) AS (SELECT b1, b2 FROM t2) " + "SELECT top(?) c1, c2, b1, b2 FROM t1, t2 WHERE t1.c1 = t2.b1", dialect.getLimitHandler().processSql(query3, selection));
// test top-based CTE with multiple CTE query_ definitions and various tab, newline spaces
final String query4 = " \n\r\tWITH a (c1, c2) AS\n\r (SELECT c1, c2 FROM t1)\n\r, b (b1, b2)\tAS\t" + "(SELECT b1, b2 FROM t2) SELECT c1, c2, b1, b2 FROM t1, t2 WHERE t1.c1 = t2.b1";
assertEquals("WITH a (c1, c2) AS\n\r (SELECT c1, c2 FROM t1)\n\r, b (b1, b2)\tAS\t(SELECT b1, b2 FROM t2)" + " SELECT top(?) c1, c2, b1, b2 FROM t1, t2 WHERE t1.c1 = t2.b1", dialect.getLimitHandler().processSql(query4, selection));
}
use of org.hibernate.query.spi.Limit in project hibernate-orm by hibernate.
the class SQLServer2012DialectTestCase method toRowSelection.
private Limit toRowSelection(int firstRow, int maxRows) {
final Limit selection = new Limit();
selection.setFirstRow(firstRow);
selection.setMaxRows(maxRows);
return selection;
}
Aggregations