mybatis-3
mybatis-3 copied to clipboard
paging query
Feature request
How about defining a new tag to implement paging query? And, to define an Page Object for the method return value.
<select_page id="selectByPage" parameterType="com.*.UserQuery" resultMap="userResultMap">
<count_sql>
select count(*) from t_user u where u.age >= #{age}
</count_sql>
<query_sql>
select * from t_user u where u.age >= #{age} order by u.age desc limit #{offset}, #{limit}
</query_sql>
</select_page>
@Repository
public interface UserMapper {
/**
* Paging query
*
* @param query
* @return
*/
Page<UserDO> selectByPage(UserQuery query);
}
@Getter
@Setter
public class Page<T> {
/**
* offset
*/
private int offset;
/**
* limit
*/
private int limit;
/**
* total
*/
private int total;
/**
* datas
*/
private List<T> datas;
}
@harawata Do you think it is necessary?
Hello @KimHu01 ,
This does not fit MyBatis design. You should use two independent selects.
I hope have offset and limit on Example object. when I generation mybatis mapper
Why not try a interceptor like this mysql-mybatis-pagination