Page<Record> pages = Db.paginate(iStartIndex/iLength+1, iLength, "select *", "from t_user where id <> '1' and isdelete <> '1' order by case when id in ("+userid+") then 0 else 1 end,"+sortFiled+" "+orderType);
这个会解析成
select count(*) from t_user where id <> '1' and isdelete <> '1' when id in ('') then 0 else 1 end,id asc
order by后面忽略了一个case导致mysql报错
我是想在分页排序的时候指定几条特定的数据在最上面
public class MyDialect extends MySqlDialect {
public String replaceOrderBy(String sql) {
return sql;
}
}
上面的自定义 MyDialect 中覆盖掉了父类的 replaceOrderBy 语句,直接 return sql即可
然后再替换掉方言: arp.setDialect(new MyDialect()),jfinal 2.3 将会改进这里,可支持任意复杂的 order by