### Question:
Mssql2008PagingTransformer extends StandardPagingTransformer { @Override public SqlNode transform(SqlNode sqlNode) { AnonymousNode result = new AnonymousNode(); for (SqlNode child : sqlNode.getChildren()) { result.appendNode(child.accept(this, null)); } return result; } Mssql2008PagingTransformer(long offset, long limit); @Override SqlNode transform(SqlNode sqlNode); @Override SqlNode visitSelectStatementNode(SelectStatementNode node, Void p);  }### Answer:
@Test public void testOffsetLimit() { String expected = "select * from ( select temp_.*, row_number() over( order by temp_.id ) as doma_rownumber_ from ( select emp.id from emp ) as temp_ ) as temp2_ where doma_rownumber_ > 5 and doma_rownumber_ <= 15"; Mssql2008PagingTransformer transformer = new Mssql2008PagingTransformer(5, 10); SqlParser parser = new SqlParser("select emp.id from emp order by emp.id"); SqlNode sqlNode = transformer.transform(parser.parse()); NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(new MockConfig(), SqlKind.SELECT, "dummyPath"); PreparedSql sql = sqlBuilder.build(sqlNode, Function.identity()); assertEquals(expected, sql.getRawSql()); }
@Test public void testOffsetOnly() { String expected = "select * from ( select temp_.*, row_number() over( order by temp_.id ) as doma_rownumber_ from ( select emp.id from emp ) as temp_ ) as temp2_ where doma_rownumber_ > 5"; Mssql2008PagingTransformer transformer = new Mssql2008PagingTransformer(5, -1); SqlParser parser = new SqlParser("select emp.id from emp order by emp.id"); SqlNode sqlNode = transformer.transform(parser.parse()); NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(new MockConfig(), SqlKind.SELECT, "dummyPath"); PreparedSql sql = sqlBuilder.build(sqlNode, Function.identity()); assertEquals(expected, sql.getRawSql()); }
@Test public void testLimitOnly() { String expected = "select top (10) emp.id from emp order by emp.id"; Mssql2008PagingTransformer transformer = new Mssql2008PagingTransformer(-1, 10); SqlParser parser = new SqlParser("select emp.id from emp order by emp.id"); SqlNode sqlNode = transformer.transform(parser.parse()); NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(new MockConfig(), SqlKind.SELECT, "dummyPath"); PreparedSql sql = sqlBuilder.build(sqlNode, Function.identity()); assertEquals(expected, sql.getRawSql()); }