- //sql语句
- String sql = "SELECT * FROM question where id<(select max(id) from question) order by id desc;";
- //创建sql查询
- Query query = Model.em().createNativeQuery(sql,Question.class);
- // 查询结果返回至实体对象question
- List<Question> questions = query.getResultList();
- //分页
- ValuePaginator paginator = new ValuePaginator(questions);
- paginator.setPageSize(20);
- paginator.setPageNumber(1);
Play framework 执行原生SQL并转换成实体对象
最新推荐文章于 2018-05-04 18:00:36 发布