SQLSERVER分页查询
mapper.xml:
select * from
(
select ROW_NUMBER() OVER(Order by id) AS RowNumber,* from newTable
where 1=1
and id = #{newtable.id}
and name = #{newtable.name}
) as b
where
b.RowNumber
BETWEEN #{pageable.offset} - #{pageable.pageSize} + 1 and #{pageable.offset}
order by name desc
整合easycode分页:
@SpringBootTest
@RunWith(SpringRunner.class)
public class SqlTest {
@Autowired
private NewtableService newtableService;
@Test
public void test01(){
Newtable newtable = new Newtable();
newtable.setId(2);
Page page = newtableService.queryByPage(newtable, PageRequest.of(1,1)); //第一页,每页一条数据
System.out.println(page);
}
}