検索系メソッドのページングとか悲観的ロックの指定はパラメータで

select時のページングとか悲観的ロックはsqlファイルで用意された元のsqlを書き換えて実行します。呼び出し時に動的に変更したいだろうからこの情報はSelectOptionsというパラメータで渡します。Daoはこんなん。

@Dao(config = MyConfig.class)
public interface EmployeeDao {
    @Select
    List<Employee> selectAll(DateDomain hiredate, SelectOptions options);
    ...
}

呼び出すときは、

List<Employee> employees = dao.selectAll(date, SelectOptions.get().limit(5).offset(3));

とか

List<Employee> employees = dao.selectAll(date, SelectOptions.get().forUpdate());

とします。

selectAllメソッドに対応する元のsql

select * from employee where hiredate = /*:hiredate*/'2000-01-01' order by employee_id

の場合、上の呼び出しはそれぞれ

select * from employee where hiredate = ? order by employee_id limit 5 offset 3

とか

select * from employee where hiredate = ? order by employee_id for update

みたいに(あらかじめ指定されたDialectに従って)変換されて実行されます。